PurabTech is technical blog for Programmer and Coders
How to configure haproxy load balancing on amazon ec2
Confused how to configure load balancer on Amazon. Here we given you detail instructions about How to configure haproxy load balancing on amazon EC2
Many people take amazon EC2 cloud hosting. Amazon does gives the load balancer for application load balancing. But Amazon load balancer is not that much good. Amazon load balancer is not working on hardware or software base. That balancer just sending request to server one by one. Many people confused how to configure load balancer on Amazon EC2.
Here I am going to give you detail instructions about setting up the HaProxy load balancer on Amazon EC2.
How to configure haproxy load balancing on amazon ec2
What is Haproxy?
AProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications. It is particularly suited for web sites crawling under very high loads while needing persistence or Layer7 processing. Supporting tens of thousands of connections is clearly realistic with todays hardware. Its mode of operation makes its integration into existing architectures very easy and riskless.
How to configure haproxy load balancing on amazon ec2
For Haproxy load balancing I recommend to create the micro instance first. Then login to micro instance and install haproxy on that machine. I taken the Centos 5.0 virgin os. Use following command for install the haproxy.
#yum install haproxy
Then Open the haproxy config file.
# vi /etc/haproxy.cfg
For detail configuration you should read the Haproxy config documentation.
Haproxy’s default load balancing style is roundrobin. Which is trusted and good. With this load balancing I am serving around two million pages daily. Means I am handling 6 to 7 million requests per day. I am not having any issues.
I used the three backend server for delivery of my application and one server for serving the static data which is having images and js and css and application files.
You can use the above code in haproxy.cfg file. You just need to change the IP address which are listed under backend static and backend app section. You just put your static server(amazon EC2 instance’s internal IP address).
You should use internal IP address of server because that will reduce the bandwidth uses of Amazon EC2 server. Do not use the public IP address for load balance because that will cost you.
Put application database and application files on all the server. Point your domain to your load balancer machine’s Public IP address.
Let say your application is running on following domain.
www.YOURDOMAIN.COM – point to Load balancer macine.
Open your all application and static server’s apache configuration file. put following entry in that file.
That is not possible to insert c++ code in haproxy config file.
Hi…
Thanks bro. i good what i need therough your blog. most import part is apache backend configuration.