Obromios
Obromios

Reputation: 16373

How to profile a production ruby on rails app's memory

My Ruby on Rails app is running on Heroku, with a dyno that has 512 Megabytes of RAM. It is using almost all the RAM right from app startup, and it only gets worse from there. I am not loading large amounts of data from the database at startup so do not understand why it is using so much memory.

How do I profile my app in production so I can understand where the memory usage is coming from? I understand that I have the option of adding another dyno or increasing the dyno memory, but I want to understand what is happening first.

Upvotes: 1

Views: 1502

Answers (1)

K M Rakibul Islam
K M Rakibul Islam

Reputation: 34318

Heroku has a log-runtime-metrics feature to monitor the memory usage.

You can run this to enable that:

heroku labs:enable log-runtime-metrics

and the memory usage will be shown on the server log.

See Heroku Labs: log-runtime-metrics for more information.

Also, you can use New Relic for the memory profiling.

See the documentation for more details.

Another awesome resource that I recommend for memory profiling is rbkit

Upvotes: 2

Related Questions