I have a simple front-end that accepts all incoming requests and serves mostly static content written in PHP. I forward qualified requests from PHP to the backend using curl and serving the responses again to the user.
I have two (the number might increase over time) similar back-ends doing the heavy lifting. I want to add load balancing (random is fine) and health checks.
All these software load balancers seem to be very complex and hard to setup. Is there an easy solution?
I thought about implementing it my self. Should be straight-forward but probably not really battle proof.
You should probably try NGINX - an HTTP and reverse proxy server. Should be easy to install and configure.
A simple front-end cloud load-balancer should be sufficient.
Enable the following apache modules :
a2enmod proxy proxy_http proxy_balancer
Then, open your /etc/apache2/conf.d/proxy-balancerconfigure
and configure the modproxybalancer by adding the following lines :
BalancerMember http://10.0.0.1
BalancerMember http://10.0.0.4
ProxyPass / balancer://mycluster
Last, configure your proxy to allow access from all hosts.
Open your /etc/apache2/mods-enabled/proxy.conf
and replace the following :
Deny from all
To
Allow from all
Restart apache using `/etc/init.d/apache2 restart``
Hope this help you.
Source : How setup a front-end cloud load balancer in apache
EDIT
For a simple health checker, add this at end of each member :
BalancerMember http://10.0.0.4 connectiontimeout=10 retry=600
EDIT2
For an advanced health checker, see apache mod_proxy_hcheck (only available for apache 2.5 and not in the official repository)
nginx is pretty easy to configure for load balancing:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.