The current common Web cluster scheduler is divided into software and hardware.
The software usually uses open source LVS, Haproxy, Nginx
The most commonly used hardware is F5, and many people use some domestic products, such as Barracuda, NSFOCUS, etc.
1.1 Haproxy application analysis
LVS has strong anti-load ability in enterprise applications, but there are some shortcomings. LVS does not support regular processing and cannot achieve dynamic and static separation. For large-scale websites, the implementation and configuration of LVS are complicated and the maintenance cost is relatively high.
Haproxy is a software that provides high availability, load balancing, and proxy based on TCP and HTTP applications. It is suitable for heavily loaded Web sites. It runs on hardware and supports tens of thousands of concurrent connections.
1.2 Haproxy scheduling algorithm
RR (Round Robin) RR algorithm is the simplest and most commonly used algorithm, namely round-robin scheduling
LC (Least Connections) minimum connections algorithm dynamically allocates front-end requests according to the number of back-end node connections.
SH (Source Hashing) is based on the source access scheduling algorithm. It is used in some scenarios where Session sessions are recorded on the server side. Cluster scheduling can be based on the source IP, Cookie, etc. For example: There are two nodes A and B, the first user first The second visit was assigned to A, the second user was assigned to B for the first visit. When the first user visits for the second time, it will continue to be assigned to A, and the second user will continue to be assigned for the second visit. To B
2. Detailed explanation of Haproxy configuration file
2.1 Global configuration global
parameter
Description
log 127.0.0.1 local0
Configure logging, local0 is the logging device, which is stored in the system log by default
log 127.0.0.1 local1 notice
Notice is the log level, usually there are 24 levels
maxconn 4096
Maximum number of connections
uid 99
User uid
guide 99
User gid
2.2 Default configuration defaults
If there is no special statement in the application component, it will be set according to the default configuration parameters
parameter
Description
log global
Define the log as the log definition in the global configuration
mode http
Mode is http
option httplog
Use http log format to record logs
retries 3
Check the node server failure for three consecutive times, the node is considered unavailable
maxconn 2000
Maximum number of connections
contimeout 5000
Connection timeout
clitimeout 5000
Client timeout
srvtimeout 5000
Server timeout
2.3 Application component configuration listen
parameter
Description
listen appli4-backup 0.0.0.0:10004
Define an appli4-backup application
option httpchk /indexhtml
Check the index.html file of the server
option persist
Force the request to be sent to the server that has been down (comment out when configuring)