Haproxy load balancing strategy

HAProxy is a free and open source software written in C language, which provides high availability, load balancing, And application proxy based on TCP and HTTP. HAProxy supports virtual hosts. The advantages of HAProxy can supplement some of the shortcomings of Nginx, such as support for Session retention and Cookie guidance. At the same time, it supports to detect the status of the back-end server by obtaining the specified url. HAProxy is similar to LVS. It is just a load balancing software. In terms of efficiency, HAProxy has a better load balancing speed than Nginx, and it is also superior to Nginx in terms of concurrent processing. HAProxy supports load balancing and forwarding of the TCP protocol. It can load balance MySQL reads, detect and load balance the back-end MySQL nodes. You can use LVS+Keepalived to load balance the MySQL master and slave.

HAProxy’s load balancing algorithms are now specifically available in the following 8 types:

①roundrobin, which means simple polling, not much to say, this is load balancing Basically available;

② static-rr, which means that according to the weight, it is recommended to pay attention;< /span>

③leastconn, which means the least connections are processed first, and it is recommended to pay attention;

④ source, which means that according to the source IP of the request, this is similar to Nginx’s IP_hash mechanism. We use it as a solution to session problems. It is recommended to pay attention to this method;

⑤ri, which means the URI according to the request;

⑥rl_param, which means according to the requested URL parameter’balance url_param’ requires an URL parameter name;

⑦hdr(name), which means that every HTTP request is locked according to the HTTP request header;< /p>

⑧rdp-cookie(name), which means to lock and hash every TCP request according to cookie(name).

Leave a Comment

Your email address will not be published.