Insights into high capacity Apache / keep alives

Hi

I have a Linode 1536 serving some web applications. I am fairly pleased with how many hits it can serve (dynamic PHP/MySQL/Apache). I'm looking for some insights on how people increase capacity, in particular how do you manage to use keep-alives without filling up every slot very very quickly. To date I've never had keep-alives turned on for production instances because of this.

Thanks.

9 Replies

@jonny5alive:

Hi

I have a Linode 1536 serving some web applications. I am fairly pleased with how many hits it can serve (dynamic PHP/MySQL/Apache). I'm looking for some insights on how people increase capacity, in particular how do you manage to use keep-alives without filling up every slot very very quickly. To date I've never had keep-alives turned on for production instances because of this.

Thanks.

You can run a light weight web server like nginx in front of apache that has keepalives on, it will serve static files itself, and pass php requests off to apache which doesn't have keepalives. There's a number of ways this should increase the number of users you can serve. 1) apache talks to nginx via localhost, so the 3 way handshake and data transfer will be lightning quick, 2) static files are no longer handled by apache which probably has mod_php loaded, which uses a lot of memory.

There's lots of other ways to reduce load, tuning mysql so it handles queries faster, apc for php, probably a 100 other things I don't know of.

Oh, and do some benchmarks with web server load testing software before and after changes so you can see you're going in the right direction.

You can also gain substantial advantage by moving to PHP-FPM (now available out-of-the-box in Ubuntu 12.04 LTS!) and using Apache's mpm-worker. Apache isn't the problem here, mod_php is.

hoopycat: Would you say PHP-FPM would be similar in performance increase as using nginx in front of Apache would be? I'd welcome not having the significantly increased complexness of nginx. (KISS)

Am I mistaken that PHP-FPM runs in Apache?

PHP-FPM runs outside of the webserver, I don't think Apache will be as fast as nginx, but you can get most of the advantages while sticking with Apache by switching to PHP-FPM and mpm_worker.

It isn't necessarily any faster, though. It'll run at the same speed. The big difference is that you can handle the same load with a lot less memory.

Good point… looking to serve more users with less resources :) Thanks all. Will make some VMs and try it all out.

My opinion (with no data to backup my opinion) is if you want to stick with apache and do what hoopycat said, it will be comparable with nginx in terms of number of concurrent users, since serving static files isn't the bottleneck, php is. apache might use more memory to serve static files, but since those files will be served so quick compared to php, it's not an issue.

That's true, although depending on the site, the static files can add up quick. It's not hard to have a few dozen static files served for a single PHP script.

Made good progress using nginx and PHP-FPM on CentOS. Nice caching and load balanced reverse proxy features were easy to figure out.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct