Score:0

Why Apache2 total threadcount is more than MaxRequestWorkers

gb flag

I recently moved my mpm from perfork to event (& also mod_php (php7.0) to php-fpm (proxy_fgi)) I estimated my max concurrent connection load to be around 300. So i set the following configuration in mpm_event.conf

StartServers                     5
MinSpareThreads          25
MaxSpareThreads          75
ThreadLimit                      64
ThreadsPerChild          35
MaxRequestWorkers         350
MaxConnectionsPerChild   0

Now I see some strange behavior when I observe the apache2 process and total threadcount using ps

Normally I have around 12-13 total apache2 processes (ps aux | grep apache2 | wc -l). Considering one to be parent.. so it is about 10-11 children. Further if I see the total threads count from apache2 with

ps -o nlwp $(pidof apache2) | tail -n +2 | awk '{ num_threads += $1 } END { print num_threads }'

I observe 408 threads for a long time.. So my questions are:

  • how is it possible that total # of threads increasing beyond MaxRequestWorkers (350)
  • how is it possible that total # of child processes increase beyond StartServers (5)
  • What is the justification for 408? (12*34?) and is my traffic hitting a limit?

Thanks for your help in advance

Score:0
in flag

I am observing similar behaviour. With default MaxRequestWorkers 150, I reach up to 301 threads - i.e. 1 parent and 2* MaxRequestWorkers threads.

I tested this by setting MaxRequestWorkers as 40 and I reached 81.

Can anyone confirm this Apache behavior?

P.S. I am running Apache2 as prefork, i.e. ThreadLimit and ThreadsPerChild are not used IMHO.

ph flag
This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://serverfault.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://serverfault.com/help/whats-reputation), you can also [add a bounty](https://serverfault.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/512409)
in flag
What I am saying is - I have a suspection number of threads reach 2* MaxRequestWorkers + 1 (parent thread). Every client request forks another thread probably because of using php. As I am using Apache in prefork mode, I can't be sure the same is also true for the event MPM.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.