I originally intended to directly use nginx reverse proxy and found that it is not easy to use. Persistent connections are not supported by default. For more information, see haproxy. Just try it ~
wget http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.21.tar.gztar -zxvf haproxy-1.4.21.tar.gz cd haproxy-1.4.21make TARGET=linux26 PREFIX=/usr/localmake install PREFIX=/usr/localcp haproxy-1.4.21/examples/haproxy.cfg /etc/haproxy.cfg
Vim/etc/haproxy. cfg:
global log 127.0.0.1 alert debug #log loghost local0 info maxconn 4096 #chroot /usr/share/haproxy uid 99 gid 99 daemon #debug #quietdefaults log global mode http option dontlognull retries 3 option redispatch maxconn 2000 contimeout 5000 clitimeout 50000 srvtimeout 50000listen rabbitmq 0.0.0.0:56720 mode tcp balance roundrobin option tcpka server rabbit1 192.168.1.93:5672 check inter 5000 downinter 500 server rabbit2 192.168.1.94:5672 check inter 5000
Port 56720 of the current machine and port 5672 of the proxy 93 and 94 rabbit machines are used.
Run in daemon mode:
Haproxy-F/etc/haproxy. cfg-d
BTW: no detailed tests and tuning have been performed.
---------------------------------------------- I am a split line ---------------------------------------------------
References:
Http://haproxy.1wt.eu/
Http://blog.chenlb.com/2009/06/install-haproxy-and-configure-load-balance.html
Http://www.joshdevins.net/2010/04/16/rabbitmq-ha-testing-with-haproxy/
Http://blog.chinaunix.net/uid-10249062-id-163273.html