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.

ApacheWorker+FastCGI+Xcache

Discussion in 'EasyApache' started by StingRay2k01, Apr 23, 2009.

  1. StingRay2k01

    StingRay2k01 Active Member

    Joined:
    Jun 15, 2003
    Messages:
    31
    Likes Received:
    1
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    I wanted to try Apache Worker because I did not want the overhead memory usage of mod_security to hit me with every request. With worker, 4/5 threads can handle a fair amount.

    I wanted to use FastCGI, because I'm coming off of mod_php and going straight to SuPHP is like going from a Corvette to a Winnebago.

    I enjoyed success using EAccelerator with mod_php but it won't work with Apache Worker. So Xcache was the next choice (it's all the rage with VBulletin people I tell ya).

    After fighting with my php.ini, zend thread safe this, extension that, I finally got Xcache to work!

    Suhosin and mod_security installed and tweaked.

    It has been an uphiill battle to get all these to work together, and I'm not done. Here are the remaining issues I'm hoping someone with more knowledge might be able to give a hint on!

    1. FastCGI occasionaly seems to spawn processes that do not close. ProcessLifeTime is set to 3500 but still some seem to orphan. If this a known bug, and if so how do others work around it? Can a setting fix this, is it my setup? How to I kill those processes (since an Apache restart does not kill them).

    2. If MaxProcessCount is 16, can more than 16 websites be accessed simultaneously? 16 unique websites = 16 different users in this case. Or once those 16 processes are used, everyone else has to wait? This is important to know so it is not set too low for the traffic.
    This also works in tandem with the Apache MaxClients.

    3. Apache Worker spawns 4/5 servers/threads and seems to be the default, I can't get it lower. Is this a built in minimum?

    Here is my config for FastCGI and Apache Worker. Which I add to the Pre-Virtual Host Include Editor.


    <IfModule mpm_worker_module>
    StartServers 2
    MaxClients 6
    MinSpareThreads 1
    MaxSpareThreads 2
    ThreadsPerChild 1
    MaxRequestsPerChild 700
    </IfModule>


    # Fastcgi configuration for PHP5
    MaxRequestsPerProcess 500
    MaxProcessCount 20
    DefaultMaxClassProcessCount 20
    IPCConnectTimeout 60
    IPCCommTimeout 60
    PHP_Fix_Pathinfo_Enable 1
    IdleTimeout 300
    IdleScanInterval 120
    BusyTimeout 300
    BusyScanInterval 120
    ErrorScanInterval 9
    ZombieScanInterval 9
    ProcessLifeTime 3600



    I've been using the Apache "ab" command to test things out, so if anyone wants to know results I get for a certain set of values, let me know.

    Any and all attempts at help are greatly appreciated! You don't even have to be polite!
     
  2. StingRay2k01

    StingRay2k01 Active Member

    Joined:
    Jun 15, 2003
    Messages:
    31
    Likes Received:
    1
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    Answering some of my own questions. Updating thread in case someone else finds it.

    1. Orphaned processes / processes not exiting - Proper setup will avoid this.


    2. MaxProcessCount is the Max. If one user uses all (16), then everyone else has to wait. However that would be very unlikely unless you have it set way too low for the amount of traffic/users on the server.

    One person viewing one web page will create one process. Two people viewing the same web page, but at different moments, will use the same process. More than one user viewing the same webpage at the same moment will create multiple processes. The "moment" is going to be short, like maybe your keepalive time (2sec on mine).

    So on a semi-busy forum with maybe 60 users listed (which means in the last 15 min usually), you will probably only use a couple processes.
    I'll be doing more testing on this, but one thing I've done is look at how many apache threads are running in this scenario in a mod_php setting as a rough comparision.


    3. Still having figured out how to get less apache threads in worker mode. It's always around 4/5. Which wastes some memory as I probably won't use them all, but not a tonne that i have to give up on it.


    Here is my current config for Apache Worker and FastCGI.
    Located in the WHM->Apache Configuration->Include Editor->Pre Virtual host Include

    Of particular interest is:
    - DefaultMinClassProcessCount 0 (necessary to make Idle timeout work)
    - ThreadStackSize (default is too high, wastes memory, the setting below is good for most and will save enough memory to allow another php thread!)


    <IfModule mpm_worker_module>
    ThreadStackSize 4000000
    ServerLimit 2
    StartServers 1
    MaxClients 128
    MinSpareThreads 1
    MaxSpareThreads 1
    ThreadsPerChild 8
    MaxRequestsPerChild 700
    TimeOut 45
    </IfModule>

    <IfModule mod_fcgid.c>
    MaxRequestsPerProcess 500
    MaxProcessCount 15
    DefaultMaxClassProcessCount 15
    DefaultMinClassProcessCount 0
    IPCConnectTimeout 60
    IPCCommTimeout 3
    PHP_Fix_Pathinfo_Enable 1
    IdleTimeout 30
    IdleScanInterval 10
    BusyTimeout 120
    BusyScanInterval 90
    ErrorScanInterval 60
    ZombieScanInterval 3
    ProcessLifeTime 120
    </IfModule>
     

Share This Page