Using 'Global Configuration' for MPM Worker

tdsm

Member
Mar 18, 2014
10
2
3
cPanel Access Level
Root Administrator
Hi all,

I've updated my MPM to Worker through EasyApache4. I am using Apache 2.4 and my confusion comes from the documentation and online advice for configuring MPM Worker and the naming conventions. I have a few questions.

At the moment, I calculate that I can safely have 6 httpd processes running without overloading the server. My understanding of MPM is that it will spawn 25 threads per process... does this mean a maximum of 150 concurrent visitors to my site?

When I configure through 'Apache Configuration' => 'Global Configuration', I have the following;

Start Servers: 2
Minimum Spare Servers: 4
Maximum Spare Servers: 4
Server Limit: 6
Max Request Workers: 6
Max Connections Per Child: 10000

Questions...

1. When I read online advice, I'm told to set Max Request Workers to Server Limit x 25 (default number of threads per process) but cPanel won't let me exceed the value of 'Server Limit'. Is this correct? Are these settings limiting me to 6 concurrent visitors or still allowing 150?

Also, just to clarify terminology;

2. Newbie question but, does one 'visitor' count for one thread or are there situations where one visitor can use up multiple threads/processes.

3. The Max Connections Per Child, is this the number of visitors that the process receives before it dies or number of 'requests', like if I have a html page which requires 1000 requests (html, css, js, images etc.) will this kill the process after 10 page loads?

Thanks so much for your help in advance!
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
Hello,

The "Max Request Workers" directive sets the limit on the number of simultaneous requests that will be served. This interface allows up to the value of the ServerLimit setting. This used to be called 'MaxClients' prior to Apache 2.4.

The MPM Worker module directs Apache to fork into several processes so that a single crash will not kill the entire Apache process. Each forked process creates numerous threads and a listener thread that listens for connections. Additional documentation is available from Apache at:

worker - Apache HTTP Server Version 2.4

Could you review this document and let us know of any additional questions?

Thank you.
 

kdean

Well-Known Member
Oct 19, 2012
377
65
78
Orlando, FL
cPanel Access Level
Root Administrator
1. When I read online advice, I'm told to set Max Request Workers to Server Limit x 25 (default number of threads per process) but cPanel won't let me exceed the value of 'Server Limit'.
The WHM Global Configuration interface doesn't properly handle Worker and Event settings. Seems like they've only thought about Prefork.

Yes, your MaxRequestWorkers setting should be 150 with a ServerLimit of 6 and a ThreadsPerChild of 25, but as you saw the WHM interface won't accept that value because it treats MaxRequestWorkers like Prefork's MaxClients setting which shouldn't exceed the ServerLimit but Worker and Event needs to allow it to exceed because of the ServerLimit x ThreadsPerChild = MaxRequestWorkers issue.

I get around it by manually editing the file.

/var/cpanel/conf/apache/local

and change the "MaxClients" setting to the correct MaxRequestWorkers value and then rebuild and restart apache. (Yes, even though you're set to Worker or Event, the cPanel config file still saves it as MaxClients even though that's not correct, but when Apache rebuilds its output correctly as MaxRequestWorkers)

Rebuild Apache script:
/scripts/rebuildhttpdconf

Restart Apache:
/scripts/restartsrv_apache


So, basically cPanel needs to fix their Global Configuration to work correctly if it is to be used with Worker and Event MPMs. Maybe even add settings for ThreadsPerChild, MinSpareThreads and MaxSpareThreads which I currently set with the Include Editor "Pre Main Include".

Code:
<IfModule worker.c>
ThreadsPerChild 25
MinSpareThreads 100
# Max must be >= (MinSpareThreads + ThreadsPerChild)
MaxSpareThreads 200
</IfModule>

<IfModule event.c>
ThreadsPerChild 25
MinSpareThreads 100
# Max must be >= (MinSpareThreads + ThreadsPerChild)
MaxSpareThreads 200
</IfModule>
 
  • Like
Reactions: The Old Man

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
Hello,

That request is archived, but I encourage you to open a new feature request for added flexibility when configuring those values:

Submit A Feature Request

Thank you.
 

sahostking

Well-Known Member
May 15, 2012
395
23
68
Cape Town, South Africa
cPanel Access Level
Root Administrator
Twitter
The WHM Global Configuration interface doesn't properly handle Worker and Event settings. Seems like they've only thought about Prefork.

Yes, your MaxRequestWorkers setting should be 150 with a ServerLimit of 6 and a ThreadsPerChild of 25, but as you saw the WHM interface won't accept that value because it treats MaxRequestWorkers like Prefork's MaxClients setting which shouldn't exceed the ServerLimit but Worker and Event needs to allow it to exceed because of the ServerLimit x ThreadsPerChild = MaxRequestWorkers issue.

I get around it by manually editing the file.

/var/cpanel/conf/apache/local

and change the "MaxClients" setting to the correct MaxRequestWorkers value and then rebuild and restart apache. (Yes, even though you're set to Worker or Event, the cPanel config file still saves it as MaxClients even though that's not correct, but when Apache rebuilds its output correctly as MaxRequestWorkers)

Rebuild Apache script:
/scripts/rebuildhttpdconf

Restart Apache:
/scripts/restartsrv_apache


So, basically cPanel needs to fix their Global Configuration to work correctly if it is to be used with Worker and Event MPMs. Maybe even add settings for ThreadsPerChild, MinSpareThreads and MaxSpareThreads which I currently set with the Include Editor "Pre Main Include".

Code:
<IfModule worker.c>
ThreadsPerChild 25
MinSpareThreads 100
# Max must be >= (MinSpareThreads + ThreadsPerChild)
MaxSpareThreads 200
</IfModule>

<IfModule event.c>
ThreadsPerChild 25
MinSpareThreads 100
# Max must be >= (MinSpareThreads + ThreadsPerChild)
MaxSpareThreads 200
</IfModule>

Interesting. This may actually explain why when we changed to MPM Event in Easy Apache and try increasing the values we still get the message to increase max request workers in error_log.

Are you saying we just add this to Pre main include and all should work fine?

<IfModule worker.c>
ThreadsPerChild 25
MinSpareThreads 100
# Max must be >= (MinSpareThreads + ThreadsPerChild)
MaxSpareThreads 200
</IfModule>

<IfModule event.c>
ThreadsPerChild 25
MinSpareThreads 100
# Max must be >= (MinSpareThreads + ThreadsPerChild)
MaxSpareThreads 200
</IfModule>
 

kdean

Well-Known Member
Oct 19, 2012
377
65
78
Orlando, FL
cPanel Access Level
Root Administrator
In addition to the Pre main includes, you need to manually modify the Apache local file and rebuild.

So, since your threads per child is 25, let's say you want MaxRequestWorkers to 1000. You would edit the Apache local file and set maxclients to 1000 and serverlimit to 40. (40 x 25 = 1000).

If you try to make these changes directly in WHM's Apache Configuration, it won't let you and will say the ServerLimit is too low. It want's you to set the ServerLimit to 1000 also, but that would technically be 25,000 workers.
 
  • Like
Reactions: The Old Man