503 error on every initial request to a Rails site

Discussion in 'Ruby/Rails' started by amaltemara, May 9, 2009.

  1. amaltemara

    amaltemara New Member

    I keep getting a 503 error the first time I pull a page from the rails app... After that, the subsequent requests pull fine with no errors..

    I'm running Litespeed Web Server Enterprise: v4.0.2
    Rails version: 2.2.2
    ruby-lsapi gem version: 3.4


    I suspect it's something to do with timeouts, and I've tried to adjust those values, and I'm not getting different results...

    There is nothing in the lsws error log for that app, there's nothing in the rails logs...

    The main error log file shows this (nothing unusual as far as I know):
    2009-05-09 13:12:35.459 [INFO] [Rails:myrailsapp.com:/] add child process pid: 11789
    2009-05-09 13:12:35.459 [INFO] [Rails:myrailsapp.com:/] pid list size: 1
    2009-05-09 13:12:35.468 [INFO] [Rails:myrailsapp.com:/] add child process pid: 11790
    2009-05-09 13:12:35.468 [INFO] [Rails:myrailsapp.com:/] pid list size: 1
    2009-05-09 13:12:35.488 [INFO] [forms.myrailsapp-RailsLSAPI] add child process pid: 11791
    2009-05-09 13:12:35.488 [INFO] [myrailsapp.com-RailsLSAPI] pid list size: 1



    I have this site set up as a Virtual Host, Rails is set up as an External App, LSAPI, with these settings:
    Max Connections: 10
    Environment: RAILS_ENV=production LSAPI_CHILDREN=10
    Initial Request Timeout: 30
    Retry Timeout: 30
    Persistent Connection: Yes
    Connection Keepalive Timeout: 20
    Response Buffering: No
    Auto Start: Yes
    Instances: 2
    Run On Start Up: Yes


    Under Context: Rails, configuration:
    Max Connections: 20




    Anyone know what I'm doing wrong??? I need this app to be rock-solid, and not give any errors like this...

    TIA

    -Anthony
  2. auser

    auser Super Moderator

    since it's first request to get 503 error, can you try increasing
    Initial Request Timeout: 30

    also wonder if
    Instances: 2
    can change to 1
    or equal to
    Max Connections: 10
  3. pguy

    pguy New Member

    Even we've faced tons of 503 issues - but there is just no clear solution and we still face it intermittently. If it continues, we may have to leave litespeed and go to passenger/apache combo
  4. amaltemara

    amaltemara New Member

    a way to troubleshoot this???


    Surely there's a way to troubleshoot exactly where the 503 is coming from??? :confused:

    When there's an error in the Rails application, and I get a 503, I know it's the rails app because I execute:
    # RAILS_ENV=production script/console
    from the command line, and I get whatever nasty bug that pops up...

    Is there a way for me to get an email notification on these 503 errors, and why they occur? Or see it in some logfile? I'm not seeing them in the logs right now...
  5. amaltemara

    amaltemara New Member

    but what does it mean??


    You have a good point, but honestly, I'm not sure if the Instances parameter would help with the initial startup... (I do have 'Auto Start: 1')

    So, I'm less inclined to try changing those values any more until I understand how they affect the process...

    Any litespeed gurus that can help shed some "light" on how these variables affect startup speed?
  6. amaltemara

    amaltemara New Member

    ???? nobody has ideas on how to troubleshoot ???

    I'm a bit at a loss... I've had to resort to a cron job every 2 mins to pull a page, just to ensure it's up...

    I have the max time set to -1, and Auto Start: Yes, so I shouldn't have to do this...

    Anyone have any clues on how to troubleshoot this 503 error??:confused::confused:
  7. amaltemara

    amaltemara New Member

    oh, and I did increase the Timeout to 60 seconds... still got the exact same symptoms...

    I timed how long it took the rails app to come up with RAILS_ENV=production script/console , and it tool about 29seconds... So 60 should be plenty!???
  8. mistwang

    mistwang LiteSpeed Staff

    Yes, you should set "Instances" to "1".
    Also try adding environment variable

    LSAPI_PGRP_MAX_IDLE=86400

    The ruby process should be started when LSWS start and stay alive. so the slow start should be avoided.
  9. mistwang

    mistwang LiteSpeed Staff

    please download the 4.0.4 release package and give it try. It should not give 503 errors when LSWS need to start a Rails application on demand.
    Just change the version number in the download link to get it.
  10. amaltemara

    amaltemara New Member

    lsws 4.0.4 fixed it, thanks!

    Thanks, lsws 4.0.4 doesn't give me the 503, thanks...
  11. bhanuprasad1981

    bhanuprasad1981 New Member

    when was 4.0.4 released how can i upgrade ?
  12. auser

    auser Super Moderator

    check the 4.0.3 download link, just change 4.0.3 to 4.0.4
  13. bhanuprasad1981

    bhanuprasad1981 New Member

    is it final or beta / testing version ?
  14. auser

    auser Super Moderator

    beta / testing version. minor difference with previous version 4.0.3.

    a convenient feature is that you can switch different versions just by a few clicks. failover to previous version is easy. so low risk to install and try a new version -- the old version still there.

Share This Page