MaxClients setting trouble

what is the proper way of figuring out MaxClients?

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. How high it should be set depends on how close the usage patterns you see push you toward 0 free memory. If you set MexClients too high and use up your available memory, your machine will start to swap, which slows the machine considerably.

@Vance is right. It's not a real error.

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?

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.

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