Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    3

    Default Limit number of php processes

    I maintain a hosting server that has like 250 domains on it. I'm facing a problem with some domains (wordpress, joomla ....) that have buggy code (memory leaks). When someone accesses those sites a lot of php processes spawn (1000-2000 processes) and consume all the RAM and SWAP and eventually the server will crash.

    Is there a way to limit the number of spawned processes? Or a way to avoid this kind of problem?

  2. #2
    BANNED
    Join Date
    Jun 2005
    Location
    Wild Wild West
    Posts
    2,025

    Default

    Quote Originally Posted by giany View Post
    I maintain a hosting server that has like 250 domains on it. I'm facing a problem with some domains (wordpress, joomla ....) that have buggy code (memory leaks). When someone accesses those sites a lot of php processes spawn (1000-2000 processes) and consume all the RAM and SWAP and eventually the server will crash.

    Is there a way to limit the number of spawned processes? Or a way to avoid this kind of problem?
    Yes you can, though 250 domains is probably pushing the limits of what you would want to host on one server particularly if those are active or heavily visited.

    You failed to tell any of us anything about your current PHP configuration so my very first question to you is what flavor of PHP are you running --

    dso, cgi, suphp, fastcgi, phpsuexec, etc?

    The type of PHP you are running will make a major difference on what you need to do settings wise and can in itself be a solution as well.

    My second question to you is whether you are running an MPM module?

    I would at the very least barebones be running MPM Prefork especially given the number of domains you are hosting though with either SuPHP or FCGI, you will have the additional option of running MPM Worker which would directly address your question about process spawning quite a bit though of those two, I would lean more towards FCGI than SuPHP in your case because FCGI utilizes a non-blocking process design that would be a bit more efficient for you in terms of process queuing and spawning and these days has the security of SuPHP but also performance exceeding that of Apache module (dso) if configured properly.

    My third question to you would be to ask you about your server's resources and more specifically how much memory do you have installed on the server first and foremost and second to that what kind of processor are you running on your server? Are you using a 32 bit or 64 bit operating system? This also can make a substantial difference.

    If you have a multiple core processor, you might be very surprised at just how many people don't realize that they have to enable the additional cores in both the operating system and server applications to make full use of their processor. Most just run their processors with one single core functioning and the stats reading out blind from the rest.

    Other than these items, you will want to take a very hard look at your Apache performance settings and what values you are using for the number of connections, spare threads (or servers), timeouts, etc
    The idea here is that you want to optimize your performance but keep those numbers in line with your actual true hardware resources.

    Anyway though, there is probably a whole lot you can do to put a leash on processes spawned and resource consumption but some more information would be needed to properly assess your best direction to go with all of that.

  3. #3
    Registered User
    Join Date
    Mar 2010
    Posts
    3

    Default

    Quote Originally Posted by Spiral View Post
    Yes you can, though 250 domains is probably pushing the limits of what you would want to host on one server particularly if those are active or heavily visited.
    I believe only aprox 50 sites are active and heavily visited. Load is like under 1 most of the time.

    Quote Originally Posted by Spiral View Post
    You failed to tell any of us anything about your current PHP configuration so my very first question to you is what flavor of PHP are you running --
    dso, cgi, suphp, fastcgi, phpsuexec, etc?

    PHP 5.2.9 (cli) (built: Nov 25 2009 16:51:12)
    Copyright (c) 1997-2009 The PHP Group
    Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
    with eAccelerator v0.9.6-rc1, Copyright (c) 2004-2007 eAccelerator, by eAccelerator
    with the ionCube PHP Loader v3.3.10, Copyright (c) 2002-2009, by ionCube Ltd., and
    with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies
    with Suhosin v0.9.29, Copyright (c) 2007, by SektionEins GmbH

    Quote Originally Posted by Spiral View Post
    The type of PHP you are running will make a major difference on what you need to do settings wise and can in itself be a solution as well.
    My second question to you is whether you are running an MPM module?
    I'm not using mpm module only prefork.


    Quote Originally Posted by Spiral View Post
    My third question to you would be to ask you about your server's resources and more specifically how much memory do you have installed on the server first and foremost and second to that what kind of processor are you running on your server? Are you using a 32 bit or 64 bit operating system? This also can make a substantial difference.
    I'm using Centos 5.4 64 bit with 6GB Ram and dual core Intel(R) Xeon(R) CPU 5130 @ 2.00GHz.

    I tried to do some performance tests for apache using the ab tool and results were ok. The only problem I have with this poorly coded plugins that cause the server to crash. Any help would be appreciated.

  4. #4
    BANNED
    Join Date
    Jun 2005
    Location
    Wild Wild West
    Posts
    2,025

    Default

    Quote Originally Posted by giany
    PHP 5.2.9 (cli) (built: Nov 25 2009 16:51:12)
    Copyright (c) 1997-2009 The PHP Group
    Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
    with eAccelerator v0.9.6-rc1, Copyright (c) 2004-2007 eAccelerator, by eAccelerator
    You didn't actually tell my what kind of PHP you have from any of that but given that you have the outdated obsolete default 5.2.9 and eAccelerator enabled, I would take a guess that you are likely DSO which means you could cut down the loads a lot changing to something else as mod_php (dso) allocates resources on each request and uses a blocking pattern where you effectively move through requests in order instead of concurrently and that amounts to more memory overhead and processing for Apache as well.

    I'm not using mpm module only prefork.
    That is a contradictory statement --- prefork *IS* an MPM module

    I'm using Centos 5.4 64 bit with 6GB Ram and dual core Intel(R) Xeon(R) CPU 5130 @ 2.00GHz.
    Don't see any real issues there ...

    I tried to do some performance tests for apache using the ab tool and results were ok. The only problem I have with this poorly coded plugins that cause the server to crash. Any help would be appreciated.
    Not sure what plugins you have but may possible be able to help there
    and I have some very slick programs that can go in and rewrite bad
    code for many programs including unknown programs in a heartbeat.

    I think upgrading and changing your PHP may help the most though.

    Anyway, I have sent you my contact info by private message ...

  5. #5
    Registered User
    Join Date
    Mar 2010
    Posts
    2

    Default

    one site in particular keeps crashing the server.
    i am having the exact same issue. i am running phpsuexec
    vps, have 1gb ram 3 cores about 30 sites only a few are active. the one that is

    most active is the one that keeps crashing the site. my host suggested i switch to fastcgi as well but i am not sure what effect it would have and if it would screw everything up b/c of file permissions. i dont believe i have mpm but wouldnt know how to check either

  6. #6
    Registered User
    Join Date
    Mar 2010
    Posts
    2

    Default

    forgot to mention its 64bit. additionally is there a way i can narrow down the code to see where the bad code is coming from?

  7. #7
    BANNED
    Join Date
    Jun 2005
    Location
    Wild Wild West
    Posts
    2,025

    Exclamation

    Quote Originally Posted by gswahhab View Post
    i am running phpsuexec
    Are you certain that you are running phpsuexec?

    This is very often commonly confused with SuPHP but if you are indeed actually running phpsuexec then I would advice that you change over to either SuPHP or FCGI as phpsuexec is quite ancient and very insecure.

    Code:
    # /usr/local/cpanel/bin/rebuild_phpconf --current | grep "PHP5"
    vps, have 1gb ram 3 cores about 30 sites only a few are active. the one that is
    Well there is why you are crashing! 30 sites on a 1 GB VPS? Eeww!

    (Disregarding the cynicism though well warranted, I might be able to help you determine what scripts, sites, and processes are most impacting your resources and bringing your server down)

    most active is the one that keeps crashing the site. my host suggested i switch to fastcgi as well but i am not sure what effect it would have and if it would screw everything up b/c of file permissions. i dont believe i have mpm but wouldnt know how to check either
    Yes, FastCGI would be infinitely better! Permissions can remain the same between phpsuexec (cgi w/ suexec), SuPHP (suphp), and FastCGI (fcgi). You only run into permission changing problems if you are changing between Apache module (dso) and anything else.

    Regarding "mpm", if you have one enabled, it is likely "prefork" ---
    Code:
    # httpd -l | grep "prefork\|worker"
    If you see "worker.c" or "prefork.c" returned from the above command then you do have an mpm module enabled though that does not necessarily mean that it is properly configured or optimized though.

  8. #8
    Member
    Join Date
    May 2003
    Posts
    613

    Default

    Quote Originally Posted by Spiral View Post
    If you have a multiple core processor, you might be very surprised at just how many people don't realize that they have to enable the additional cores in both the operating system and server applications to make full use of their processor. Most just run their processors with one single core functioning and the stats reading out blind from the rest.If you have a multiple core processor, you might be very surprised at just how many people don't realize that they have to enable the additional cores in both the operating system and server applications to make full use of their processor. Most just run their processors with one single core functioning and the stats reading out blind from the rest.
    Could you give some brief pointers as to how to check whether the OS, Apache, PHP & MySQL are utilising all the processor cores available, both physical and virtual cores as in Hyper-Threading?

Similar Threads & Tags
Similar threads

  1. Limiting Number of PHP processes spawned w/ mod_fcgid ??
    By wizzy420 in forum cPanel and WHM Discussions
    Replies: 18
    Last Post: 06-23-2010, 08:57 AM
  2. Limit FCGI Processes
    By GrG in forum cPanel Developers
    Replies: 1
    Last Post: 05-30-2010, 06:38 AM
  3. Limit Number of Domains
    By wedohosting.com in forum cPanel and WHM Discussions
    Replies: 6
    Last Post: 09-23-2006, 08:17 PM
  4. Number of mysql processes
    By Berbox in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 05-05-2006, 12:03 PM
  5. Is there a limit on the number of directories?
    By bhills in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 06-10-2003, 11:41 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube