Home >Backend Development >PHP Tutorial >Detailed explanation of Apache's implementation of Web Server load balancing (regardless of Session version)_PHP tutorial
At least three servers are required:
Server A: control server
Server B and Server C: actual execution server
Load balancing principle: Distribute requests to access server A to Server B and Server C
Modify the http.conf file of apache on Server A:
First, load the corresponding proxy module and remove the # sign in front of the following modules:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Secondly, add at the end of the file:
ProxyPass /example/ balancer://proxy/
BalancerMember http://serverB /example/
BalancerMember http://serverC/example/
means to distribute all files in the http://serverA/example/ subdirectory of server A to servers B and C for execution, which is equivalent to accessing http://serverB/example/ or http://serverC/example / subdirectory files.
If written as:
ProxyPass / balancer://proxy/
BalancerMember http://serverB/
BalancerMember http ://serverC/
means that all requests to access A are accordingly converted to access B or C
Finally, restart the apache of server A