In this post we will show you how to easily setup loadbalancing for your web application. Imagine you currently have your application on one webserver called web01:
1
2
3
4
5
6
7
|
+---------+
| uplink |
+---------+
|
+---------+
| web01 |
+---------+
|
But traffic has grown and you’d like to increase your site’s capacity by adding more webservers (web02 and web03), aswell as eliminate the single point of failure in your current setup (if web01 has an outage the site will be offline).
1
2
3
4
5
6
7
8
9
|
+---------+
| uplink |
+---------+
|
+-------------+-------------+
| | |
+---------+ +---------+ +---------+
| web01 | | web02 | | web03 |
+---------+ +---------+ +---------+
|
In order to spread traffic evenly over your three web servers, we could install an extra server to proxy all the traffic an balance it over the webservers. In this post we will use HAProxy, an open source TCP/HTTP load balancer. (see: http://haproxy.1wt.eu/) to do that:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
+---------+
| uplink |
+---------+
|
+
|
+---------+
| loadb01 |
+---------+
|
+-------------+-------------+
| | |
+---------+ +---------+ +---------+
| web01 | | web02 | | web03 |
+---------+ +---------+ +---------+
|
So our setup now is:
– Three webservers, web01 (192.168.0.1), web02 (192.168.0.2 ), and web03 (192.168.0.3) each serving the application
– A new server (loadb01, ip: (192.168.0.100 )) with Ubuntu installed. 继续阅读 →