23

I'm hosting a rails application on Heroku.

Is there a way I could track the memory usage of the running dynos?

Peter DeWeese
  • 18,141
  • 8
  • 79
  • 101
Oded Harth
  • 4,367
  • 9
  • 35
  • 62

4 Answers4

31

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

To enable, run

$ heroku labs:enable log-runtime-metrics

and the memory usage will be shown on the server log. Read Heroku log-runtime-metrics docs for more information.

shinnc
  • 899
  • 7
  • 16
8

I would advice you to open an account on New Relic.

More information here :

http://newrelic.com/docs/ruby/new-relic-for-ruby

and here :

http://devcenter.heroku.com/articles/newrelic

Jef
  • 5,424
  • 26
  • 28
  • Heroscale is a scaling service, nothing to do with monitoring running dynos memory usage – Neil Middleton Jan 24 '12 at 12:41
  • @Neil yes, I mentioned it as a monitoring/scaling-related solution. I should have added it. – Jef Jan 24 '12 at 12:45
  • 1
    I've talked with support. 'Server Monitoring' from New Relic doesn't work on Heroku. You need to have access to server to install their agent. – Sergii Mostovyi Feb 04 '14 at 06:22
  • It's worth noting that New Relic does support heroku instance monitoring. For ruby with unicorn, each unicorn worker is considered an instance. The memory usage only shows averages across all instances though, and it's not terribly accurate compared to heroku's log-runtime-metrics per shinnyx's answer. With NR you can't really identify spikes in memory usage, although the graph supposedly shows a min/max. The numbers don't seem entirely accurate though. My `num instances * avg mem = 1200mb`, while I am only running 2 1x dynos for a max of 1024mb. – agmin May 05 '14 at 20:02
3

None of the answers provide a good way to track the memory usage of dynos, especially if you want to separate stack & heap usage from shared libraries, etc.

In my answer to another SO question I provide code that takes detailed snapshots of process memory usage and adds the ability to do threshold-based diffing to identify the areas with changing memory usage over time.

Here is the gist with the code for tracking the memory footprint of Heroku dynos.

Community
  • 1
  • 1
Sim
  • 13,147
  • 9
  • 66
  • 95
0

Using the Heroku New Relic Standard addon - it's free and it's awesome, plus it has a specific 'Dynos' tab when used via Heroku.

John Beynon
  • 37,398
  • 8
  • 88
  • 97