WebFaction
Community site: login faq

I have deployed two apps on WebFaction. The output of passenger-memory-stats contains:

27626  261.6 MB   54.8 MB  Rack: /home/<username>/webapps/app1/current
31603  398.5 MB   60.3 MB  Passenger RackApp: /home/<username>/webapps/app2/current

app1 was deployed with Ruby 1.9, and app2 (which is newer) was deployed with Ruby 2.0.

Is it really normal for Passenger RackApp to take up 60 MB of memory? Keep in mind that my account has only 256 MB of memory, and I plan to replace my Drupal web sites with Rails web sites.

I should note that I originally used the gem called "therubyracer" to provide the Javascript runtime for app2, but I installed node.js, removed "therubyracer" from my Gemfile, and used "bundle install" to implement this omission. Despite this improvement, Passenger RackApp still consumes 60 MB (as you can see from my above results), just as much as before. Also, these sites don't have that much traffic yet.

If it isn't normal for Passenger RackApp to use 60 MB of memory, what else can I do to reduce its memory usage WITHOUT jeopardizing performance?

asked 19 Jun '13, 00:03

dopplervalue...
45158
accept rate: 100%


You will reach your 256 MB memory usage limit soon based on my experience managing sinatra-passenger apps on 256 MB RAM server.

For a comparison, in my 256 MB server, I use ruby 1.9, sinatra, and passenger to serve 3 apps. These are the memory usages under low traffic.

747246  226.4 MB   28.3 MB  Rack: /home/<username>/webapps/app1/current
843158  295.9 MB   24.4 MB  Rack: /home/<username>/webapps/app2/current
852753  202.4 MB   23.2 MB  Rack: /home/<username>/webapps/app3/current

I think your memory usage is normal for rails apps because sinatra is just a microframework while rails is a very huge framework.

Under low traffic your app uses 60 MB of memory. That's just 1 passenger process using 60 MB. Under moderate traffic, Passenger will spawn more processes each of which using 60 MB. So your apps will take [number of process] x 60 MB.

According to this nginx-passenger configuration guide about PassengerMaxPoolSize, passenger--by default, will use maximum of 6 processes to handle requests.

One of my sinatra-passenger apps reached 6 processes limit just by serving about 200-300 concurrent requests in the early days of my-first-time-deployment at webfaction server. That's 6 x 30 MB === 180 MB for just 1 app. I also got many "Memory usage way over your limit" messages from webfaction because I've used up my RAM quota.

My problem was solved just by setting the PassengerMaxPoolSize to 2. It's fine so far. I never had to increase the PassengerMaxPoolSize to handle requests for my sinatra-passenger apps.

You could start by setting each of your app PassengerMaxPoolSize to 1. I hope it's enough for your webapp's needs. If you have to increase your max pool size to handle more requests, I think you should upgrade your RAM or move to a server that provides more RAM per account.

You also can find more methods of reducing your apps RAM usage from webfaction's reducing memory usage guide

permanent link

answered 19 Jun '13, 10:00

mavbozo
111
accept rate: 0%

Thanks. How many users (or how much bandwidth) can one Rails process handle?

If it's normal for a low-traffic Rails web site to consume 60 MB of memory, then I'm reconsidering my plans to replace my existing Drupal sites with Rails sites. Would Django have a smaller memory footprint than Rails? If so, how much smaller?

(19 Jun '13, 10:59) dopplervalue...

Thanks. How many users (or how much bandwidth) can one Rails process handle?

There's no general answer for that. You'd have to perform your own load testing to determine what your site can handle.

If it's normal for a low-traffic Rails web site to consume 60 MB of memory, then I'm reconsidering my plans to replace my existing Drupal sites with Rails sites.

Drupal has a high memory footprint as well. The difference is that with Drupal, your php-cgi process only last long enough to serve a single request, so you don't get long-term high memory usage.

Would Django have a smaller memory footprint than Rails? If so, how much smaller?

Again, there's no general way to determine that - you'd need to test your code under both platforms to compare them.

(19 Jun '13, 11:35) seanf

These numbers look pretty normal to us. Passenger and Rails tend to use quite a bit of memory (moreso, for instance, than mod_wsgi and Django).

I'm not aware of a way to reduce this without jeopardizing performance.

permanent link

answered 19 Jun '13, 03:22

ryans ♦♦
5.0k93160
accept rate: 43%

edited 19 Jun '13, 03:23

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×108
×87
×25

question asked: 19 Jun '13, 00:03

question was seen: 6,464 times

last updated: 19 Jun '13, 11:35

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM