I'm looking into options for creating a highly available site on web faction. As far as I've been able to tell, the only option is to set up two identical sites and use DNS round robin. Are there any other options? For example, is there a way to use something like haproxy to balance between sites on two different servers? Or perhaps by using an Apache module (mod_jk / mod_proxy*)? I realize that I'm likely limited to web application-only solutions, and that I would have to handle database replication. My primary goal is to be able to push site updates without downtime (by turning off one site, upgrading it, then repeating the process with the other site). asked 22 Apr '15, 19:12 _S_ |
I'm personally not familiar with haproxy, but I know it's dead-simple to do load balancing with Nginx. First create a 'custom app listening on port' application to reserve a port for your Nginx load balancer. For the rest of this example, I'll assume that this app is named "load_balancer" and its been assigned port 54321. Go ahead and assign that app to a website in the panel as well. After you've created the app in the control panel, SSH into your server and run the following commands to build Nginx:
Next, edit your `~/webapps/load_balancer/conf/nginx.conf to set the port and configure the backend servers that it's going to balance:
Finally, start your Nginx server:
At that point, the site to which you assigned the load_balancer application will be proxying requests to server1.domain.com and server2.domain.com, round-robin style. If you want it to handle traffic more-intelligently, you can use the any of the various load-balancing methods described in the Nginx load-balancing guide. For example, if you want to use the
Also, note that the backend server configuration above includes the port numbers (random in this example) for the other servers. Be sure to use the "open port" option for those apps on the other servers. Just remember to restart or reload your Nginx whenever you modify the config. I'm sure you could do something similar with haproxy, if that's your tool-of-choice. I don't know the exact procedure, butt the core concepts should be the same:
Hope that helps!
permanent link
This answer is marked "community wiki".
answered 22 Apr '15, 23:40 seanf |