Max Apache / PHP Concurrent Connections?

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
User avatar
Kadanis
Forum Contributor
Posts: 180
Joined: Tue Jun 20, 2006 8:55 am
Location: Dorset, UK
Contact:

Max Apache / PHP Concurrent Connections?

Post by Kadanis »

Background:
I'm working on a site at the moment for quite a large client. They have a tracking system for their newsletters that picks up stuff like click throughs opens etc by replacing all links with a link to their site along with a link code on the url. The page then redirects them to the actual link via a redirect based on data from a mysql db using the link code. Pretty standard stuff I imagine. I've seen it a few times before.

Anyway, during the test phase they were sending to around 10'000 employees and everything worked fine. Since moving to live they are now sending to around 100'000 employees / clients etc and the tracking is going crazy. Hardly anything it coming through. The 100'000 gets sent out in around 3 hours, in over night batches.

One of the points put forward for investigation was this...

Is there a limit to the amount of hits that apache/php can handle in a space of time. For example if lots of people all accessed the links (via the tracking page) at the same time, would apache/php failed to handle the requests.

The website is hosted at a pretty serious datacentre, right on the UK backbone, with over 100Mbps connections to the Internet and client has unlimited use, so I don't think bandwidth is an issue

Any advice here would be great as I seem to have been dumped with the job of producing a document on why the tracking failed so miserably...
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

There is a max number of clients at any one time:

Code: Select all

# prefork MPM
# StartServers ......... number of server processes to start
# MinSpareServers ...... minimum number of server processes which are kept spare
# MaxSpareServers ...... maximum number of server processes which are kept spare
# MaxClients ........... maximum number of server processes allowed to start
# MaxRequestsPerChild .. maximum number of requests a server process serves
<IfModule prefork.c>
StartServers         5
MinSpareServers      5
MaxSpareServers     10
MaxClients          20
MaxRequestsPerChild  0
</IfModule>

# pthread MPM
# StartServers ......... initial  number of server processes to start
# MaxClients ........... maximum  number of server processes allowed to start
# MinSpareThreads ...... minimum  number of worker threads which are kept spare
# MaxSpareThreads ...... maximum  number of worker threads which are kept spare
# ThreadsPerChild ...... constant number of worker threads in each server process
# MaxRequestsPerChild .. maximum  number of requests a server process serves
<IfModule worker.c>
StartServers         2
MaxClients         150 
MinSpareThreads     25
MaxSpareThreads     75
ThreadsPerChild     25
MaxRequestsPerChild  0
</IfModule>

# perchild MPM
# NumServers ........... constant number of server processes
# StartThreads ......... initial  number of worker threads in each server process
# MinSpareThreads ...... minimum  number of worker threads which are kept spare
# MaxSpareThreads ...... maximum  number of worker threads which are kept spare
# MaxThreadsPerChild ... maximum  number of worker threads in each server process
# MaxRequestsPerChild .. maximum  number of connections per server process (then it dies)
<IfModule perchild.c>
NumServers           5
StartThreads         5
MinSpareThreads      5
MaxSpareThreads     10
MaxThreadsPerChild  20
MaxRequestsPerChild  0
AcceptMutex fcntl
</IfModule>
If you have a server that's being constantly hammered you'll want StartrServers to be high (this is the number of processes that sits waiting as soon as apache starts), Trun you KeepAliveTimeout right down. They have it on some stupidly high value by default by in this day and age it needn't be more than 2 seconds. Having it high means you'll have processes lingering when they needn't be. Basically, you want to tweak the values so that you can quickly get a process open, run the request and ditch any excess process. Apache optimization can be tricky business and it's something you just have to keep tweaking over time til it feels right.

I can't give you step-by-step guidance since I alomost always am tweaking apache to use lower memory loads on quiet servers whereas you're trying to do the opposite. There are lots of guides online for optimizing apache.

If you run MySQL and you DONT use InnoDB, add "skip-innodb" to my.cnf since that uses heaps of memory if you don't. I could go on forever, but I won't :P
User avatar
Kadanis
Forum Contributor
Posts: 180
Joined: Tue Jun 20, 2006 8:55 am
Location: Dorset, UK
Contact:

Post by Kadanis »

Thanks for the advice.

I seem to have gravitated to the right area, as I have the httpd.conf open at exactly that point, just wasn't sure what next.

I've have a play and tweak around a bit to see what happens.

I'll also look at the Mysql setting. I think they're running MyISAM, so that could also be beneficial.

Thanks again :)
Post Reply