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.

Prevent scripts from exploding

Discussion in 'Workarounds and Optimization' started by Eli L, Sep 14, 2010.

  1. Eli L

    Eli L Well-Known Member

    Joined:
    Aug 9, 2007
    Messages:
    61
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    Bellingham, Washington, United States
    cPanel Access Level:
    Root Administrator
    I had a user on my system that had a script that kept creating process after process until the server ran out of memory and crashed (buggy script, not on purpose). The following is what the script did:

    Code:
    USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
    root     16401  0.0  0.6 145848 55884 ?        Ss   Sep10   0:42 /usr/local/apache/bin/httpd -k start -DSSL
    nobody   10157  0.0  0.5 146112 48724 ?        S    05:11   0:00  \_ /usr/local/apache/bin/httpd -k start -DSSL
    user123 14004  0.0  0.0  29964  2448 ?        S    07:43   0:00  |   \_ /usr/bin/python index.cgi
    user123 14005  0.0  0.0  27780  3212 ?        S    07:43   0:00  |   |   \_ python updateerrorpages.py
    user123 14006  0.0  0.0  29964  3476 ?        S    07:43   0:00  |   |       \_ python /home/user123/public_html/main/templates/index.py
    user123 14007  0.0  0.0  27780  3212 ?        S    07:43   0:00  |   |           \_ python updateerrorpages.py
    user123 14008  0.0  0.0  29964  3472 ?        S    07:43   0:00  |   |               \_ python /home/user123/public_html/main/templates/index.py
    user123 14009  0.0  0.0  27780  3212 ?        S    07:43   0:00  |   |                   \_ python updateerrorpages.py
    user123 14010  0.0  0.0  29964  3472 ?        S    07:43   0:00  |   |                       \_ python /home/user123/public_html/main/templates/index.py
    user123 14011  0.0  0.0  27780  3212 ?        S    07:43   0:00  |   |                           \_ python updateerrorpages.py
    user123 14012  0.0  0.0  29964  3476 ?        S    07:43   0:00  |   |                               \_ python /home/user123/public_html/main/templates/index.py
    user123 14013  0.0  0.0  27780  3212 ?        S    07:43   0:00  |   |                                   \_ python updateerrorpages.py
    user123 14014  0.0  0.0  29964  3472 ?        S    07:43   0:00  |   |                                       \_ python /home/user123/public_html/main/templates/index.py
    user123 14015  0.0  0.0  27780  3212 ?        S    07:43   0:00  |   |                                           \_ python updateerrorpages.py
    user123 14016  0.0  0.0  29964  3472 ?        S    07:43   0:00  |   |                                               \_ python /home/user123/public_html/main/templates/index.py
    user123 14017  0.0  0.0  27780  3216 ?        S    07:43   0:00  |   |                                                   \_ python updateerrorpages.py
    user123 14018  0.0  0.0  29964  3476 ?        S    07:43   0:00  |   |                                                       \_ python /home/user123/public_html/main/templates/index.py
    user123 14019  0.0  0.0  27780  3208 ?        S    07:43   0:00  |   |                                                           \_ python updateerrorpages.py
    ..........keeps going until server runs out of ram....
    My question is how do I prevent and/or stop scripts like this from exploding and going out of control before my server crashes?

    Thanks, help is very appreciated.
     
    #1 Eli L, Sep 14, 2010
    Last edited: Sep 14, 2010
  2. Liam D.

    Liam D. Member

    Joined:
    Sep 14, 2010
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    I think its either:

    Code:
    WHM (root) > Apache Configuration > Global Configuration > MaxRequestsPerChild
    Change the value to your liking.

    OR

    Code:
    WHM (root) > PHP Configuration Editor > memory_limit AND  	max_execution_time AND max_input_time
    Try lowering their values. But you should probably wait for other answers just in case.

    ;)
     
  3. Eli L

    Eli L Well-Known Member

    Joined:
    Aug 9, 2007
    Messages:
    61
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    Bellingham, Washington, United States
    cPanel Access Level:
    Root Administrator
    Thank you, I lowered the MaxRequestsPerChild and see how that does.

    Your 2nd suggestion is only for php and the problematic script was cgi/python.
     
  4. GaryT

    GaryT Well-Known Member

    Joined:
    May 19, 2010
    Messages:
    321
    Likes Received:
    3
    Trophy Points:
    16
    I have never really thought about this untill now, But why is the MaxRequestsPerChild default set to 10000 ? Is this not rather HIGH !

    Setting it to zero is bad I assume and uncontrolable memory but I can only assume putting it to 10 is reasonable ?

    Someone care to update me and confirm a few things please.


    Thanks.
     
Loading...
Similar Threads - Prevent scripts exploding
  1. Forcerdj
    Replies:
    4
    Views:
    494

Share This Page