These forums are read-only!
Swapping problem for Rails app
  • I have a Rails 2.3.8 app hosted and running on slicehost (256M). I am not familiar at all with the back-end, I basically followed the steps from the slicehost tutorials to install Apache. The memory usage being very high, I then changed my Apache conf file to reduce the MaxClient number to 10... but my slice is still swapping.

    Here is what the memory usage I get after just a few clicks on my site:

    top - 23:57:12 up 28 min, 2 users, load average: 0.43, 0.54, 0.30
    Tasks: 79 total, 1 running, 78 sleeping, 0 stopped, 0 zombie
    Cpu(s): 0.1%us, 0.1%sy, 0.0%ni, 97.8%id, 0.1%wa, 0.0%hi, 0.0%si, 2.0%st
    Mem: 262364k total, 258656k used, 3708k free, 260k buffers
    Swap: 524280k total, 262772k used, 261508k free, 6328k cached

    PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
    4004 web-app 20 0 178m 72m 1888 S 0 28.4 0:04.38 ruby1.8
    4001 web-app 20 0 172m 61m 1932 S 0 24.2 0:02.72 ruby1.8
    3941 root 20 0 164m 57m 1672 S 0 22.5 0:21.44 ruby
    3990 web-app 20 0 209m 21m 1696 S 0 8.4 0:18.00 ruby1.8
    3950 web-app 20 0 165m 7464 1548 S 0 2.8 0:20.40 ruby1.8
    3684 mysql 20 0 224m 6504 2084 S 0 2.5 0:14.34 mysqld
    3938 root 20 0 53632 3048 1036 S 1 1.2 0:01.50 starling
    3839 root 20 0 243m 1456 1248 S 0 0.6 0:00.34 apache2
    3897 www-data 20 0 243m 1452 1072 S 0 0.6 0:00.04 apache2
    3894 www-data 20 0 243m 1368 1008 S 0 0.5 0:00.04 apache2
    3895 www-data 20 0 243m 1220 960 S 0 0.5 0:00.02 apache2
    3888 root 20 0 46520 1204 1100 S 0 0.5 0:02.29 ruby1.8
    3866 root 20 0 17648 1184 896 S 0 0.5 0:00.08 bash
    3896 www-data 20 0 243m 1180 952 S 0 0.4 0:00.00 apache2
    3964 www-data 20 0 243m 1164 956 S 0 0.4 0:00.02 apache2
    3892 www-data 20 0 243m 1132 956 S 0 0.4 0:00.00 apache2
    3948 www-data 20 0 243m 1132 956 S 0 0.4 0:00.00 apache2
    3962 www-data 20 0 243m 1132 956 S 0 0.4 0:00.02 apache2
    3963 www-data 20 0 243m 1132 956 S 0 0.4 0:00.00 apache2
    3965 www-data 20 0 243m 1080 888 S 0 0.4 0:00.00 apache2
    3887 root 20 0 89008 960 796 S 0 0.4 0:00.00 ApplicationPool


    I'm not sure what to do next... I could upgrade to a larger slice but for now I have almost no traffic on this app, so I think it's more a problem with my configuration or maybe my code?

    Any concrete recommendations would be welcome! Thanks
  • So you have 262772k used swap .. that's a lot and will likely cause a noticeable slowdown.

    Also I'd like to point out that the 22% memory usage per ruby process is 22% of what all programs are using .. so might be more than 22% of actual RAM .. if you get my drift .. so it'll always add up to 100% .. but might be 250% of RAM.

    I'd look at using less ruby processes .. if you're using 'mongrels' for deployment .. maybe look at using fusion passenger.

    This link has a lot of good info.

    Also if you can rebuild to a 32 bit Slice, that might help a bit .. 32 bit generally uses a little less RAM. NB: 'rebuild' == wipe the Slice clean, including any rails installations..

  • Switch to 32 bit slice, install http://www.rubyenterpriseedition.com/ instead of your distros ruby, use passenger, all those will help but on a 256 box you'll have a hard time handling many clients using RoR.
  • Let's face it, who cares[url=http://www.dvdtopshop.com/en/tv-series-dvd-boxset/house-m-d-seasons-1-6-dvd-boxset.html]house md dvd[/url] what they call "reality" TV anymore? Hugh Laurie breathes new life into the genre with Medical House MD, the best show in years. Laurie's brilliant performance[url=http://www.dvdtopshop.com/en/comedy/greys-anatomy-seasons-1-6-dvd-boxset.html]grey's anatomy dvd[/url] coupled with a distribution very supportive and some impressive celebrity guest stars, which quickly became one of my favorite television shows. If no signs of slowing down, I[url=http://www.dvdtopshop.com/en/sci-fi-fantasy-/smallville-seasons-1-9-dvd-boxset.html]smallville dvd[/url] hope the House will continue for many seasons, viewers worldwide can provide fresh and fabulously original episodes each week. Bryan Singer (X-Men, Superman) handles[url=http://www.dvdtopshop.com/en/animation-cartoons/walt-disneys-100-years-of-magic-164-discs-dvd-boxset.html]walt disney dvd[/url] the material well with a firm hand, shaping the show, while supporting cast room to breathe. Music, rhythm, and excellent writing to David Shore each paymet memorable. DVD has [url=http://www.dvdtopshop.com/en/tv-series-dvd-boxset/the-closer-seasons-1-5-dvd-boxset-.html]the closer dvd[/url]all 22 episodes of the groundbreaking drama, and it's great to have so much to entertain the fans satisfied.If show only others would take note of the House, there is actually something else watching television.