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.

Using 'Global Configuration' for MPM Worker

Discussion in 'EasyApache' started by tdsm, Apr 28, 2016.

Tags:
  1. tdsm

    tdsm Registered

    Joined:
    Mar 18, 2014
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    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!
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,811
    Likes Received:
    671
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
  3. kdean

    kdean Well-Known Member

    Joined:
    Oct 19, 2012
    Messages:
    262
    Likes Received:
    12
    Trophy Points:
    18
    Location:
    Orlando, FL
    cPanel Access Level:
    Root Administrator
    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>
    
     
  4. kdean

    kdean Well-Known Member

    Joined:
    Oct 19, 2012
    Messages:
    262
    Likes Received:
    12
    Trophy Points:
    18
    Location:
    Orlando, FL
    cPanel Access Level:
    Root Administrator
    Someone posted a Feature Request on this 2 years ago but it's apparently "Archived" now whatever that means. Maybe it wasn't clear to cPanel when it was submitted.

    apache 2.4 MaxRequestWorkers
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,811
    Likes Received:
    671
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  6. sahostking

    sahostking Well-Known Member

    Joined:
    May 15, 2012
    Messages:
    300
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Cape Town, South Africa
    cPanel Access Level:
    Root Administrator

    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>
     
  7. kdean

    kdean Well-Known Member

    Joined:
    Oct 19, 2012
    Messages:
    262
    Likes Received:
    12
    Trophy Points:
    18
    Location:
    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.
     
Loading...

Share This Page