Phusion Passenger processes show very different memory usage

Viewed 47

Here's the output of passenger-status from production:

  * PID: 24388   Sessions: 0       Processed: 103069   Uptime: 2d 22h 47m 44s
    CPU: 3%      Memory  : 1376M   Last used: 19s
  * PID: 2380    Sessions: 0       Processed: 2844    Uptime: 21h 6m 28s
    CPU: 0%      Memory  : 575M    Last used: 1m 4s ag
  * PID: 4192    Sessions: 0       Processed: 44      Uptime: 5h 59m 21s
    CPU: 0%      Memory  : 315M    Last used: 7m 40s a

Notice the difference in memory consumption of the three processes. Is this normal? Or does this mean that my application is leaking memory, and therefore, the memory usage is correlated with the number of requests served by each process (which is expected to be "lopsided" as explained in the docs)?

PS: This is a Ruby on Rails app, btw.

1 Answers

Is this normal? Yes.

Passenger will balance the load of requests across the instances in precedential order of there "freedom". In your case (as it is for most) the first instance serves the most requests because it has the highest precedence. If instance 1 is busy then passenger will try instance 2, then instance 3 and so on.

Does this mean my application is leaking memory? I do not have insight into your code base but the most likely answer in this context is no.

The instance of the application will continue to grow (to a point) based on the Objects loaded into memory. Rails uses auto loading so that it does not load Objects until their first use (depending on config). Constants like (classes, modules, global variables, etc) will stick around forever in your application memory and other objects will be garbage collected (sooner or later) along the way. This combination is likely what you are seeing.

Related