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.

cpanel resource limit ?

Discussion in 'Workarounds and Optimization' started by Le1, Oct 20, 2010.

  1. Le1

    Le1 Registered

    Joined:
    Feb 9, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Hello everyone,

    I'm searching in google but without any result.
    I have a simple question, is it possible to limit resource for each domain ?
    for example limit max cpu usage, max memory usage etc. for every domain ?

    Thanks...
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    You can limit such usage, but you would need to do it in Apache usually. The way to limit it will be dependent on your PHP handler, so are you using DSO, suPHP, CGI or FCGI for your handler?
     
  3. Le1

    Le1 Registered

    Joined:
    Feb 9, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    I'm using suPHP
     
  4. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    For DSO and suPHP, you can use RLimitMEM and RLimitCPU to restrict memory and CPU for accounts. Those would be placed into httpd.conf

    There's actually a setting to restrict it in WHM > Apache Configuration > Memory Usage Restrictions area. That automatically sets it and you can then view the settings by doing in root SSH:

    Code:
    grep -i rlimit /usr/local/apache/conf/httpd.conf
     
  5. Le1

    Le1 Registered

    Joined:
    Feb 9, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Thanks for answer, it's working now :)
     
  6. GaryT

    GaryT Well-Known Member

    Joined:
    May 19, 2010
    Messages:
    321
    Likes Received:
    3
    Trophy Points:
    16
    Tristian, Hi

    How would you go on about putting limits in place for when using fast cgi ?
     
  7. mikelegg

    mikelegg Well-Known Member

    Joined:
    Mar 29, 2005
    Messages:
    330
    Likes Received:
    0
    Trophy Points:
    16
    Correct me if I'm wrong, but RLimitCPU sets a limit on the amount of time for maximum CPU usage of a process, but it doesn't limit how much of the CPU a process can use.

    Limiting CPU resources by percentage per user would require a custom kernel.

    If you haven't seen this already it's an interesting read Shared Hosting CPU Protection Is Here!!! « mattheaton.com
     
  8. JamesCartelo

    JamesCartelo Registered

    Joined:
    Nov 9, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    You may also able to edit your httpd.conf and modify RLimitCPU by giving other values to this . and then restart you apache...
     
  9. GaryT

    GaryT Well-Known Member

    Joined:
    May 19, 2010
    Messages:
    321
    Likes Received:
    3
    Trophy Points:
    16
    Ho through, I see default of:

    RLimitCPU 230 or 240, somewhere along those line.. This is default per WHM.. so when they say 240 ect what does that actually mean.. And it this per domain and such..

    I would like more answers
     
  10. RCraft

    RCraft Well-Known Member

    Joined:
    Nov 7, 2010
    Messages:
    52
    Likes Received:
    0
    Trophy Points:
    6
    Another value you may wish to add is RLimitNProc - this caps the number of processes they can have at any time (this is also highly recommended for anyone running CloudLinux). On our budget hosting servers we use RLimitNProc 15 25

    15 is the soft limit - 25 is the hard limit. You can raise the limits on a per user basis in the .htaccess file by adding RLimitNProc 25 (for example) into their .htaccess.

    Also, if you're editing the httpd.conf manually be sure to run this after:

    /usr/local/cpanel/bin/apache_conf_distiller --update

    Otherwise the next time CPanel writes to the httpd.conf your changes will be lost.
     
  11. GaryT

    GaryT Well-Known Member

    Joined:
    May 19, 2010
    Messages:
    321
    Likes Received:
    3
    Trophy Points:
    16
    So in theory, In:

    you would add the following example:

    And by doing this no domain shall go over those figures ?
     
  12. RCraft

    RCraft Well-Known Member

    Joined:
    Nov 7, 2010
    Messages:
    52
    Likes Received:
    0
    Trophy Points:
    6

    That setting would restrict them to 5 running processes at a time which is not many - each time someone visits the site they execute a process via the index page. Most of the time it should execute immediately and then die, but sometimes it doesn't. Also, if they get any kind of real traffic then 5 processes isn't much (and this takes into account imap processes as well - we've had customers who have 10 or 15 imap connections who hit the soft limit of 15 running processes).

    The hard cap of 15 would be something you'd have to set manually in their .htaccess in order for them to be able to exceed the 5 process limit.

    Thus, I'd recommend at the very least, 10 running processes per user on budget type hosting. Anything less then that is incredibly restrictive and they will get 500 errors on their sites when they hit the cap, so you will know about it quick, fast and in a hurry.
     
  13. GaryT

    GaryT Well-Known Member

    Joined:
    May 19, 2010
    Messages:
    321
    Likes Received:
    3
    Trophy Points:
    16
    The reason I ask is I'm on litespeed php which has roughly the same function but this can be set via Admin Panel and not through terminal.

    I'm just wondering thats all, But I do appreciate your responses, You made things clear, Im sure others will thank you for it to ;)
     
  14. RCraft

    RCraft Well-Known Member

    Joined:
    Nov 7, 2010
    Messages:
    52
    Likes Received:
    0
    Trophy Points:
    6
    Ah, I see. Well, hope it does help someone out - we run this setting on all of our servers and it's been a life saver. The RLimit settings are fairly obscure and there's not a lot about them out there.
     
  15. GaryT

    GaryT Well-Known Member

    Joined:
    May 19, 2010
    Messages:
    321
    Likes Received:
    3
    Trophy Points:
    16
    In Litespeed its called:

    I'm sure what you explained will do exactly the same, Now In LSWS I have this set to 8, It never achives this as there open and closed immediatly once expired where apache seems to hold them longer.
     
Loading...

Share This Page