Apache Global Configuration for MPM Event

linux4me2

Well-Known Member
Aug 21, 2015
259
76
28
USA
cPanel Access Level
Root Administrator
I realized from reading another thread that some of the settings in WHM -> Service Configuration -> Apache Configuration -> Global Configuration are for MPM Prefork and not those recommended for MPM Event.

The Apache documents for Start Servers, Server Limit, Max Request Workers, and Max Connections Per Child suggest that those settings for MPM Event should be:
  • Start Servers: 3
  • Server Limit: 16
  • Max Request Workers: 400
  • Max Connections Per Child: 0 (or cPanel's default of 10000 to limit memory leakage)
From reading about optimization of MPM Event, it looks like there are a couple of settings--Threads Per Child and Thread Limit--that are not available in Global Configuration, but are apparently fine left at the defaults of 25 and 64, respectively.

If I set the Start Servers, Server Limit, Max Request Workers, and Max Connections Per Child in Global Configuration to the values listed above and restart Apache, will those values be used for MPM Event and the default values used for the two settings that aren't in Gobal Configuration, or do I need to explicitly set the Threads Per Child and Thread Limit according to the instructions in Manually Edit Apache Features?
 

Zoltan Szabo

Active Member
Jul 13, 2017
41
8
8
Hungary
cPanel Access Level
Root Administrator
I have recently moved to MPM event from Prefork ergo this is a super relevant question for me also!

After reading this article (link below) and what Linux4Me2 wrote I am sure that the default apache global settings needs to be changed.
Tuning/Optimizing Apache on cPanel Servers - Northon Torga

I would like to see the answer for the question of Linux4Me2!

I also like to ask about a bug in capanel. Is that still there? The article sasy:
"The only trick here is, you have to set ServerLimit to 512 and MaxRequestWorkers to 400 and rebuild. Then, you set ServerLimit to 16 and rebuild. cPanel has a “bug” that force MaxRequestWorkes to be smaller or equal to ServerLimit, if both are changed the same time. When you change only ServerLimit in the second time, MaxRequestWorkes won’t be touched."

Best,
Z
 
Last edited:
  • Like
Reactions: linux4me2

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,202
363
Hello,

The performance-related options in "WHM >> Apache Configuration >> Global Configuration" are intended for the Prefork MPM. You will notice the following under the "Notes" section for some of the values in the corresponding document:

  • To configure this setting in EasyApache 4, you must install the MPM Prefork module.
Configuring those values via Web Host Manager for the Worker and Event MPMs is not supported at this time. There's a thread on this topic at:

Using 'Global Configuration' for MPM Worker

Additionally, I recommend opening a feature request to add support for the Worker and Event MPMs when configuring these settings in WHM.

Thank you.
 
  • Like
Reactions: linux4me2

Zoltan Szabo

Active Member
Jul 13, 2017
41
8
8
Hungary
cPanel Access Level
Root Administrator
Hello,

The performance-related options in "WHM >> Apache Configuration >> Global Configuration" are intended for the Prefork MPM. You will notice the following under the "Notes" section for some of the values in the corresponding document:
Hello Michael,

If I got you right changing values in apache global configuration only has affect on prefork MPM!! ?
So what you mean is placing this in e.g. pre_main would solve the issue

<IfModule event.c>
ServerLimit 16
MaxClients 400
StartServers 3
ThreadsPerChild 25
ThreadLimit 64
</IfModule>

Is this correct? Sorry, I am not sure in the placement of this config or whether its even necessary!
Can we somehow print the current settings?
I touched nothing so far just switched to MPM event!


Bye,
Z
 
  • Like
Reactions: linux4me2

linux4me2

Well-Known Member
Aug 21, 2015
259
76
28
USA
cPanel Access Level
Root Administrator
According to the thread Using 'Global Configuration' for MPM Worker, it sounds like you need to add the:

<IfModule event.c>
ServerLimit 16
MaxClients 400
StartServers 3
ThreadsPerChild 25
ThreadLimit 64
</IfModule>

to the Pre-main Include as well as modifying the Apache local file and rebuilding, but since these are the default values for MPM Event, maybe that's not necessary? If there were a way to output the current settings being used by Apache as @Zoltan Szabo inquired, we would be able to tell if any modifications are necessary.

I added the feature request.
 
Last edited:
  • Like
Reactions: Zoltan Szabo

linux4me2

Well-Known Member
Aug 21, 2015
259
76
28
USA
cPanel Access Level
Root Administrator
I read the manual for httpd, and I couldn't find a way to output the values of the current settings for MPM Event.

It doesn't make sense to me that one would have to add parameters to both the Pre-main include and /var/cpanel/conf/apache/local. If the Apache Global Configuration UI does eventually include a way to configure MPM Event, it makes sense to me that the way it would work is that it would modify /var/cpanel/conf/apache/local and then restart Apache. I tested this by taking a look at /var/cpanel/conf/apache/local, then changing my Start Servers setting from 5 to 3 in the Global Configuration UI. I looked at /var/cpanel/conf/apache/local again, and the setting there had changed to 3. That leads me to assume--maybe incorrectly--that all I really need to do for MPM Event is to change the settings in Apache's Global Configuration that correspond to the settings I want to use for MPM Event to the correct values (Server Limit, Max Request Workers, and Start Servers), and either not do anything for Threads Per Child and Thread Limit since they aren't currently in the Global Configuration UI, or add them to /var/cpanel/conf/apache/local.

If I look at the list of available directives in the Apache Directive Quick Reference, there are a lot of them that don't appear in my /var/cpanel/conf/apache/local. That makes me suspect that the default values are used if there are no local settings. Since I want the defaults for Threads Per Child and Thread Limit, I'm thinking I don't have to add them to /var/cpanel/conf/apache/local.

If someone who actually knows how this stuff works doesn't correct me, I'm thinking about giving it a try.
 

linux4me2

Well-Known Member
Aug 21, 2015
259
76
28
USA
cPanel Access Level
Root Administrator
The Global Configuration UI wouldn't let me change Max Request Workers to the 400 that is recommended for Event MPM, so I went ahead and edited /var/cpanel/conf/apache/local, setting it there, and while I was in there, added entries for Threads Per Child (25) and Thread Limit (64), ran /scripts/rebuildhttpdconf to rebuild the httpd conf, and restarted Apache.

So far, nothing has broken. (Fingers crossed.)
 

Zoltan Szabo

Active Member
Jul 13, 2017
41
8
8
Hungary
cPanel Access Level
Root Administrator
The Global Configuration UI wouldn't let me change Max Request Workers to the 400 that is recommended for Event MPM, so I went ahead and edited /var/cpanel/conf/apache/local, setting it there, and while I was in there, added entries for Threads Per Child (25) and Thread Limit (64), ran /scripts/rebuildhttpdconf to rebuild the httpd conf, and restarted Apache.

So far, nothing has broken. (Fingers crossed.)
"The only trick here is, you have to set ServerLimit to 512 and MaxRequestWorkers to 400 and rebuild. Then, you set ServerLimit to 16 and rebuild. cPanel has a “bug” that force MaxRequestWorkes to be smaller or equal to ServerLimit, if both are changed the same time. When you change only ServerLimit in the second time, MaxRequestWorkes won’t be touched."

Can anyone from Cpanel please confirm that changing Apache Global config is the right way for MPM event?
Also a method to check current settings would be appreciated!

Bye
Z

@linux4me2 So far I have no complaints for my sites so I just wait till it turns out if I need to do anything or just use apache global (unfortunately 2 times because the mentioned bug)
 

Zoltan Szabo

Active Member
Jul 13, 2017
41
8
8
Hungary
cPanel Access Level
Root Administrator
All right everybody, I was also brave and did the changes, and works all right!

I have done this in apache global config.
With the trick of double saving (server limit first 512 and second down to 16) it works direct from WHM!
See the screenshot of my current settings in WHM
I beleive the not touched 2 extra settings (ThreadsPerChild, ThreadLimit) keeps to be the default value for MPM event
Event though it would be a nice feature to test current settings, somehow ?

My sources apart from this forum:
This link helps a lot with explanation and they also used cpanel!
Tuning/Optimizing Apache on cPanel Servers - Northon Torga

If you want to learn more of MPM event and apache optimisation this is an excellent writing.
And did really highlighted the path for my apache optimisation!
Apache - Apache 2.4 Event optimization guide
 

Attachments

linuxman1

Member
Aug 25, 2017
14
0
1
Egypt
cPanel Access Level
Root Administrator
My issue with Enent MPM and Cpanel is I can't find any good docs from Cpanel on how to optimize this MPM and where to find the defaults that Cpanel uses so we may optimize it for different scenarios even from CLI!