MaxClients setting trouble
I am getting
[error] server reached MaxClients setting, consider raising the MaxClients
settings for
/etc/apache2/apache2.conf
KeepAlive on
MaxKeepAliveRequests 100
KeepAliveTimeout 4
StartServers 1
MinSpareServers 3
MaxSpareServers 6
ServerLimit 24
MaxClients 24
MaxRequestsPerChild 3000
then I got the same error
[error] server reached MaxClients setting, consider raising the MaxClients
I up the number on ServerLimit and MaxClients to 36. I still get the error.
What is a proper way to figure out the actual number?
Thank you.
6 Replies
@superdupler:
[error] server reached MaxClients setting, consider raising the MaxClients
This is nothing to be overly concerned about. Additional requests will be queued and served once a process becomes available (I'm assuming you are using the prefork MPM). It only becomes a problem if users have to wait a considerable time for pages to be served to them.
You should set MaxClients to a low enough number so that you never reach 0 free memory on the -/+ buffers/cache line
Rule of thumb: If you use Apache with mod_PHP and MySQL, MaxClients should be no more than RAM / 25MB. So if your RAM is 512MB, MaxClients should be no more than 20.
You can increase it a bit if your scripts are lightweight, or decrease it if you have RAM-intensive scripts such as an image gallery. Disregard the "server reached MaxClients" error, and just focus on page-load performance.
ServerLimit should be the same as MaxClients.
Also, try reducing KeepAliveTimeout to 2, and see if it helps reduce the number of unnecessary error messages. (This kicks off idle clients sooner, so that the queue can be processed faster.)
That seems excessive, and Apache with mod_php is probably going to use more than 25MB of RAM a pop, no?
excessive…what do you mean? You dont agree it should be 20. Why?
Right now, I made KeepAliveTimeout 2 and ServerLimit 20, MaxClients 20.
However, I would like to figure out the right number. Thank you.
@Guspaz:
That seems excessive, and Apache with mod_php is probably going to use more than 25MB of RAM a pop, no?
Most scripts get by just fine with a memory_limit of 32MB, and in fact average much less than that, unless your CMS is loaded with a bunch of bloated plugins. In my opinion, an average figure of 25MB is a good enough approximation for any bread-and-butter PHP app that doesn't handle large images.
Also, a significant percentage of your Apache processes will be serving static files at any given time. Even with mpm_prefork, serving a static file doesn't use much RAM. It'll show up as ~13MB because of the PHP engine, but almost all of that is shared. So you'll still have some RAM left for MySQL, buffers, and cache.
Anyway, I said "no more than RAM / 25MB". You are unlikely to OOM under normal conditions if you stick to this formula, but the ideal value could be somewhat lower.