|
|
|
|
|
by zh
4632 days ago
|
|
NginX is very good WEB SERVER - so it shines in serving content - web pages, caching images etc. But in proxy mode, the load-balancing between backends is pretty basic.
HAProxy is born to be very good LOAD BALANCER - you can have different balancing algorithms, not only round-robin.
HAProxy have also TCP mode, so you can balance your MySQL backends, for example.
Also for me, personally, HAProxy stats rock. |
|
We used haproxy to do close to zero downtime migration of our postgres servers (and other stuff) from one data centre to another recently when we moved out of our old data centre: Set up a slave in the new dc, set up haproxy with the slave as backup, point all the clients to haproxy. Shut down the master, and as soon as the master stopped responding, haproxy would shove clients to the slave in the new data centre instead. Then touch the trigger file to make the slave recover and switch to master mode.
It meant we were in read-only mode because requests where going to the slaves for about 2-3 seconds (and unlike MySQL Postgres does not allow writes to a slave until it's been promoted) before the slave started handling updates - other than that everything just chugged along.