Ask HN: Ideas for load balancing under Apache?
* Solution must be a low-cost solution as money is a determining factor here. * Client currently only has 2 VPS servers (and can't afford to get more) * Server specs are: 2.3 GHz monocore CPU, 1 GB RAM, 20 GB SSD Storage (both of them). * Both servers are running Debian 7.5 Wheezy. * Client has already installed and running zPanel in one of the servers and has configured a series of Wordpress sites. * Client uses some WP Plugins to generate content, this hangs the server every time as CPU consumption is a lot. * I have transfered the DB Server to the second server to help leverage the load. * Client can't afford downtime in the websites. * Just managed to convince him that zPanel would not be necessary (I will write a couple of bash scripts to automate vhost creation and wordpress configuration).
My question/challenge here is: How can I help leverage CPU load in the server with little to no downtime? I have read about HAPROXY and I know for sure that this would be relatively easy with nginx, but the main setup is done with Apache and one of the sites refused to work properly under nginx (still can't figure out why, probably .htaccess or the use of some other Apache Module, I haven't investigated enough). Any ideas? Any help is much appreciated.
7 comments
[ 3.1 ms ] story [ 24.6 ms ] threadAs for the WordPress sites, I would make sure there is at least a caching plugin installed for each of the sites.
1. Web services (http), how much traffic? What version of PHP? Did you shut down all unnecessary modules?
2. Inbound traffic (content generation) These processes are creating content on the fly, or writing to the DB?
Reality is it would cost you less (time is money), to put in a couple of multi-core processors and 4Gs of RAM, and its going to be necessary if traffic continues to grow.
Also you can offload much of the static serving load to AWS S3. There is a CDN for Wordpress that's free too.
At the very least, get the numbers for:
This will tell you where you need to concentrate your performance improvement efforts on.Also, look at solutions that are easy to implement and offer immense benefit for very low effort like server-side caching (eg:https://github.com/BenjaminAdams/wp-redis-cache / http://www.jimwestergren.com/wordpress-with-redis-as-a-front... )
cheers,
[1] Your statement that Client uses some WP Plugins to generate content, this hangs the server every time as CPU consumption is a lot. is an alert.
I have been analyzing its code and it's not optimized at all (not that I was surprised when I found out), it seems to not have any kind of limitant on how many posts it creates on the wordpress site (it creates posts to the DB) and it hogs up all resources. I have convinced my friend/client that the best way is to avoid using that plugin for now until it is optimized (by me, obviously... sigh), and it seems like we will start using some kind of caching system as well as CDNs to leverage the toll the sites take with traffic (I'm not really worried about that).
All in all, I guess it'll come up as a total rewrite of the plugin he is using and implementing a caching system along with a CDN system for static files as suggested in your comments.
Thanks a lot again for all your help!
Thanks for the suggestion!