Hello,
I just quickly try load balancing on Apache, it works well. It’s free and there is no need for other software or plug-ins. It works on all platforms and it works with ssl without changing the existing settings.
Unfortunately I do not have time to look in depth at the moment. There must have errors and it should be optimized, but for those who want to try, it works.
I am assuming that you already have an Apache server (Linux, Windows…) and web apps configured in reverse proxy.
For each subdomain (each vitualhost), enter the following code in the Apache configuration file:
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
To inject a cookie tracking in each request. This cookie will allow each session (each browser I think) will always follow the same path/app, even if there are several sessions that use the same IP.
<Proxy "balancer://mycluster">
BalancerMember "http://127.0.0.1:8035" route=app1
BalancerMember "http://127.0.0.1:8030" route=app2
ProxySet lbmethod=bybusyness
ProxySet stickysession=ROUTEID
</Proxy>
Here, we see that two xojo web apps (http://127.0.0.1:8035 and http://127.0.0.1:8030) share the same address (the same subdomain of the virtualhost). Of course, you can run more applications. Requests redirected to the first app will have an “app1” cookie, and those that are redirected to the second app will have an “app2” cookie.
We indicate also that the load balancing method will be “bybusiness”. I’ve had good results with this method, but can-be that others are better.
Finally, we indicate that once a browser was directed to a web app, it must always be directed to this app for the following requests, by following the ROUTEID cookie (app1 ou app2).
ProxyPassMatch ^(/.*)$ balancer://mycluster$1
This last line of code replaces the proxypass directives, so all requests go to the load balancing.
Thats all. Not forget to activate the modules by uncommenting:
LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Do not use this code in production, this is just a proof of concept. There must be errors. but improve it and please publish the code in comment…
For those seeking an already robust code, there are excellent articles of John on Nginx and HAproxy.
sorry for my bad English…