mxgoncharov
mxgoncharov

Reputation: 525

Phusion Passenger consumes a lot of RAM

I have RoR app, which uses Passenger + Nginx.

Also I have ImageMagick for some regular tasks with images.

In one day (yesterday-tomorrow) I saw that my app crashes, in case out of memory!

ImageMagick write to log 'Cannot allocate memory'.

When I check free RAM, I saw that there only ~120MB free. (Summary is 1GB).

Most part used Passenger.

I had restarted it, and all became OK.

What reason of this can be?

Upvotes: 0

Views: 879

Answers (1)

Jan Strnádek
Jan Strnádek

Reputation: 808

  1. First of all, did you use all functions of ImageMagick, if not change ImageMagick to MiniMagick (you save part of memory).

  2. Next thing image processing, how do you work with images? Always you can do it asynchronously (resque/sidekiq/rake task in cron - "smaller solution"), you can maybe save some MB..

  3. Passenger, is quite memory demanding. Try something smaller like Thin / Puma.

  4. Are you sure, your code is without memory-leaks? If you're using ruby 2.1+ there is several tools to detect it, for example excelent article, or if not, try to run your application in JRuby with Java memory profiler, for example VisualVM

some other question to think, did you really need full Rails? Rails is big and require quite a lot memory, maybe Sinatra or for simple API Grape can be sufficient...

Upvotes: 1

Related Questions