Getting Lots of Ruby Processes

Discussion in 'Ruby/Rails' started by jp_n9, Sep 11, 2006.

  1. xing

    xing LiteSpeed Staff

    That's it. The installation overwrites the ruby-lsapi library file in the global ruby folder of your os.

    No need to modify your app. Though to be extra safe, the final "install" step should be performed with no ruby/rails process running just to make sure old libs are overwritten without problem.
  2. mistwang

    mistwang LiteSpeed Staff

    To be safe, do "gem uninstall ruby-lsapi" to make sure the gem version is removed.
  3. jp_n9

    jp_n9 New Member

    I uninstalled the gem, just to make sure.

    I have the latest version of LiteSpeed installed, and LSAPI 1.8. It has been about 7 hours since I restarted the server - and I now have 26 processes running.

    Max connections is set to 10. Is there any other configuration variable somewhere that could be set incorrectly and leading to this???

    Here is what is in the log:

    2006-09-15 00:35:01.639 INFO [127.0.0.1:52875-0#Example] File not found [/usr/bin/DEFAULT/html/whm-server-status]
    2006-09-15 00:40:02.608 INFO [127.0.0.1:53698-0#Example] File not found [/usr/bin/DEFAULT/html/whm-server-status]
    2006-09-15 00:41:28.491 INFO [65.111.164.187:54922-0#VHOSTNAMEREMOVED] Index file is not available in [/home/xxxxxxx/releases/20060911024632/public/]
    2006-09-15 00:45:02.298 INFO [127.0.0.1:54471-0#Example] File not found [/usr/bin/DEFAULT/html/whm-server-status]
    2006-09-15 00:46:31.095 NOTICE [Rails:VHOSTNAMEREMOVED:/] stop worker processes
    Last edited: Sep 15, 2006
  4. amalik

    amalik New Member

    I think you are within the limit based on the Max Connections setting. It was kind of confusing for me too, but this is what I am doing now.

    • Figure out how many processes you can afford on your vps or shared account
    • Divide it by 3, and set your MAX Connections to that number.

    NOTE: EACH virtual host you set has to have its own Max Conn. setting. It is not global as far as I can tell, so if you have 3 vhosts at 10 each, you're looking at maybe 10*3*2 at the very least if the load increases , that is a LOT of ram because RoR is a frikkin Hog when it comes to real RAM usage. So, for 3 vhosts at 10 max each and a "reasonable" default behaviour of going to "twice the configured value" as described by litespeedtech, you are looking at 10 * 3 * 2 * 20mb = 1.2 GB or RES mem usage, obviously, if you have less than that available, your system will start hitting the swap, it will delay the request serving by the RoR, and that would feed the vicious cycle. pretty soon, you could start thrashing.

    Unfortunately the documentation is not clear on how many processes each lsapi process can handle. If this was clear, then people won't set it to 10.. 10 *20 *3 is more than half gig of ACTUAL ram, and most people don't have that even on a VPS system.


    Suggestion (to litespeedtech):
    Put a tool tip next to the Max Connections entry which says, "LSWS may start upto 3 times as many rails processes (at 20mb each) as this setting"

    This will be a clear warning to us all that this setting can be resource intensive.
    Last edited: Sep 15, 2006
  5. jp_n9

    jp_n9 New Member

    Well if what you are saying is correct, then I'm not sure adding a tool tip is the solution.

    If the "Max Connections" value is supposed to control the maximum processes created, then it should not create any more processes than the value you enter there. Maximum != Maximum * 3. It just doesn't make sense. Of course, the wording itself is already confusing, does "Connection" == "Ruby Process"?

    Also, I'm not sure if that "Max Connection" value is supposed to be for the server or per Rails Application. Being that it is in the Server Tuning section - it would seem as though it should be a Server wide setting. Regardless how many Rails apps are installed, no more than the Maximum value should be started.
  6. mistwang

    mistwang LiteSpeed Staff

  7. jp_n9

    jp_n9 New Member

    What is the correlation between the "Max Connections" value under the Rails tab and the "Max Connections" under the "Tuning" tab? Does one have precedence over the other?
  8. mistwang

    mistwang LiteSpeed Staff

    They are not related.

    "Max connections" under "Tuning" tab is the maximum connections that LSWS can handle. All active connections included.

    "Max connections" under "Rails" tab is the maximum number of connections that LSWS uses to communicate with backend ruby engine.
  9. jp_n9

    jp_n9 New Member

    Is the max connections under "Tuning" also multiplied by 3? What is the resource cost of each "connection" under the "Tuning" tab?
  10. mistwang

    mistwang LiteSpeed Staff

    No, it is not. The resource cost is number of file descriptors, no need to worry about that. "300" is the max value for the current standard edition, which is enough for pretty large website.

  11. jp_n9

    jp_n9 New Member

    I reset the "Max Connections" under the "Rails" tab to 3. I restarted, and a few hours later I now have 12 ruby processes. This is kind of crazy.

    Under the "Security" tab there is a setting "Max CGI Instances" which is left at the original 20. Could that or anything else be causing this issue?

    Any other ideas?
  12. mistwang

    mistwang LiteSpeed Staff

    "Max CGI instances" does not matter.
    If possible, please PM me temp root access and admin for LSWS web interface to your server, I'd like to take a look.
  13. amalik

    amalik New Member

    Can you post to this thread what the problems was when it is resolved?

    thanks,

    Amr
  14. mistwang

    mistwang LiteSpeed Staff

    OK, caught the bug on jp_n9's server, it only happens when ruby processes are started in suEXEC mode, user id is different from that of web server, and "max_idle_time" under "Rails" tab has been set.

    When there is no request to ruby process for "max_idle_time", LSWS will try to kill this process group, but failed due to permission problem, but LSWS think the process group has been killed, when next request comes in, LSWS will start another group of ruby process, and so on.

    I have updated ruby-lsapi-1.8 package to address this issue, please update your installation then and add an environment variable "LSAPI_PGRP_MAX_IDLE=xxx" under "Rails" tab to tell the ruby process to quit, the value should match "max idle time" value under rails tab.

    We will fix this problem on LSWS side as well in 2.2.2, by finding a workaround for the permission problem of killing suEXEC processes, as well as setting "LSAPI_PGRP_MAX_IDLE" automatically.
  15. jp_n9

    jp_n9 New Member


    Did you fix this bug on my server? Because I just checked and there are 14 processes right now.

    If you didn't fix it, what do I need to do?
  16. mistwang

    mistwang LiteSpeed Staff

    No, I did not. You need to download ruby-lsapi-1.8 package and install it again and add an environment variable "LSAPI_PGRP_MAX_IDLE=xxx" under "Rails" tab to tell the ruby process to quit, the value should match "max idle time" value under rails tab.
  17. amalik

    amalik New Member

    mistwang, thanks for posting it back here. Hopefully we'll get the gem soon enough. I'm just going to keep killing the processes as it is in dev anyway.

    thanks,

    Amr
  18. jp_n9

    jp_n9 New Member

    Well the server has been left unchecked all weekend, and today I only have one Ruby process running. Looks like it worked. Thanks!
  19. mistwang

    mistwang LiteSpeed Staff

    Thank you for the update, we will release LSWS 2.2.2 and ruby LSAPI 1.8 soon.

Share This Page