Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Ideas for load balancing under Apache?
1 point by JohnQUnknown on May 14, 2014 | hide | past | favorite | 7 comments
I am currently facing a challenge were I must load balance a series of domains for a client/friend, but there are some issues that I've been unable to fix just yet, allow me to explain:

* 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.




Hello again and thanks for your responses, I have been analyzing the server performance and checked logs for when CPU peaks and I know now, as I previously stated, that the issue is when that particular plugin (Traffic Commando) runs.

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!


You could run the plugin as a cron job on off-peak traffic hours.


I actually did that, I disabled the wp-cron function and switched to crontab. I am currently monitoring the server to see if this helps or if the issue is somewhere else.

Thanks for the suggestion!


You could use Cloudflare and their free level.

As for the WordPress sites, I would make sure there is at least a caching plugin installed for each of the sites.


Replace your two crappy VPSes with one slightly less crappy VPS.


My recommendation would be to actually measure the performance of the servers, isolate and address any possible bottle-necks in the application side of things[1] before attempting to solve the problem using load-balancing. If, for instance the problem is with your DB or with the communication with the DB, splitting the incoming traffic really won't help much and depending on the actual case, might worsen the situation.

At the very least, get the numbers for:

  1. Response time for a single static file request
  2. Response time for a non-db php request (eg: phpinfo() )
  3. Response time from the application for a non-db request
  4. Response time from the application with a db request
  5. .... with/without plugins ...you get the idea
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'm not sure what your goal is here... manage CPU load or traffic load? Sounds like you have a couple of problems.

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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: