The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Apache Global Configuration for MPM Event

Discussion in 'EasyApache' started by linux4me2, Jul 20, 2017.

Tags:
  1. linux4me2

    linux4me2 Well-Known Member

    Joined:
    Aug 21, 2015
    Messages:
    149
    Likes Received:
    34
    Trophy Points:
    28
    Location:
    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?
     
  2. Zoltan Szabo

    Zoltan Szabo Member

    Joined:
    Jul 13, 2017
    Messages:
    18
    Likes Received:
    4
    Trophy Points:
    3
    Location:
    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
     
    #2 Zoltan Szabo, Jul 21, 2017
    Last edited: Jul 21, 2017
    linux4me2 likes this.
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,064
    Likes Received:
    1,287
    Trophy Points:
    363
    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:

    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.
     
    linux4me2 likes this.
  4. Zoltan Szabo

    Zoltan Szabo Member

    Joined:
    Jul 13, 2017
    Messages:
    18
    Likes Received:
    4
    Trophy Points:
    3
    Location:
    Hungary
    cPanel Access Level:
    Root Administrator
    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
     
    linux4me2 likes this.
  5. linux4me2

    linux4me2 Well-Known Member

    Joined:
    Aug 21, 2015
    Messages:
    149
    Likes Received:
    34
    Trophy Points:
    28
    Location:
    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.
     
    #5 linux4me2, Jul 21, 2017
    Last edited: Jul 21, 2017
    Zoltan Szabo likes this.
  6. linux4me2

    linux4me2 Well-Known Member

    Joined:
    Aug 21, 2015
    Messages:
    149
    Likes Received:
    34
    Trophy Points:
    28
    Location:
    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.
     
  7. linux4me2

    linux4me2 Well-Known Member

    Joined:
    Aug 21, 2015
    Messages:
    149
    Likes Received:
    34
    Trophy Points:
    28
    Location:
    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.)
     
  8. Zoltan Szabo

    Zoltan Szabo Member

    Joined:
    Jul 13, 2017
    Messages:
    18
    Likes Received:
    4
    Trophy Points:
    3
    Location:
    Hungary
    cPanel Access Level:
    Root Administrator
    "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)
     
  9. Zoltan Szabo

    Zoltan Szabo Member

    Joined:
    Jul 13, 2017
    Messages:
    18
    Likes Received:
    4
    Trophy Points:
    3
    Location:
    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
     

    Attached Files:

    cPanelMichael and linux4me2 like this.
  10. linux4me2

    linux4me2 Well-Known Member

    Joined:
    Aug 21, 2015
    Messages:
    149
    Likes Received:
    34
    Trophy Points:
    28
    Location:
    USA
    cPanel Access Level:
    Root Administrator
  11. linux4me2

    linux4me2 Well-Known Member

    Joined:
    Aug 21, 2015
    Messages:
    149
    Likes Received:
    34
    Trophy Points:
    28
    Location:
    USA
    cPanel Access Level:
    Root Administrator
    @cPanelMichael I think you can mark this one solved. The workaround described here seems to work just fine.
     
    cPanelMichael likes this.
  12. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,064
    Likes Received:
    1,287
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    linux4me2 likes this.
Loading...

Share This Page