Can anyone recommend a config, or better yet point me to a full case study for this web setup?
Basically we have a php site getting about 100,000 hits per day. It's already getting connection timeouts etc. when trying to serve this load on a VPS, due to hitting CPU capacity. I'd like to spec something that will allow it to scale to about 250,000 hits per day.
Currently the server is:
- a single-core 1Ghz burstable VPS (from a 2.6Ghz dual core Xeon)
- 2GB burstable RAM (again, I find burstable very vague)
- 32MB per php process, running expression engine (as far as I know) or something similarly heavy
- quite image-intensive graphical pages
- occasional behind-the-scenes work on some pages, like xmlrpc to third-party servers
- plain apache with modphp (so static files like images also need full php processes -- this can't be changed for now)
So far, CPU seems to be the main bottle neck, with some apache process using around 30% CPU during requests. Some other apache processes seem much better at only 1% CPU; I assume these are requests for static files.
So. We want to get away from the VPS onto some sort of dedicated or virtual dedicated box with non-burst (measurable, guaranteed) performance. It has to be able to handle currnet traffic and at least double that in future.
Any recommendations or studies you can point me to?
Are there any tools around which can give you an estimated server spec based on parameters like memory per apache process, percentage of requests that are dynamic, whether PHP code is heavy CMS stuff or lightweight hello-world stuff, etc?
I doubt there are any useful case studies on this matter as performance will always vary enormously based on the complexity of the application - the only way to get close to a fit is to measure and extrapolate.
You don't mention OS but I'd setup a series of performance monitors capturing threads, cpu loads, memory stats, disk and network data etc. also make sure you capture the number of hits you're dealing with. From this you should be able to determine the min, average and max resource usage for all these components based on actual seen load - once you have these stats (mhz/10k-users, mem/10k-users etc) you should be able to quickly extrapolate the performance you need. Make sure to plan for around 20% additional headroom even when at your peak expected load.
I know it's a lot of spreadsheet work but it's the only way you'll feel confident - well there's always the 'throw tons of hardware at the problem' method which works too but costs :)
Best of luck and come back with some data later if you need help understanding it.
Just add nginx in proxy mode in front of apache, and set it up to server really static data without touching apache. You will fell instant speed boost.
Then I would switch apache2 into preforked mode with like 4-16 childs.
Background work like external connections really hurts, I would rewrite that code to make these things async.
Finally, you might be out of bandwidth on master node (i.e. server holding all VPSses). Ask you hosting company if they have 1Gbit connection on their master node, and if it's just 100Mbit - you might want to change hosting.