Rails 3 + Heroku: Find out dyno's memory usage

heroku, ruby-on-rails-3

Solution

There's also a native Heroku way to do this now. Heroku rolled out a labs feature log runtime metrics which will inject CPU load and memory usage information into the logging stream. These logs come with a source ID (e.g. "web.1") and a dyno unique ID, so that you can tell the dynos apart. It looks something like this:

source=web.1 dyno=heroku.2808254.d97d0ea7-cf3d-411b-b453-d2943a50b456 sample#load_avg_1m=2.46 sample#load_avg_5m=1.06 sample#load_avg_15m=0.99
source=web.1 dyno=heroku.2808254.d97d0ea7-cf3d-411b-b453-d2943a50b456 sample#memory_total=21.00MB sample#memory_rss=21.22MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=348836pages sample#memory_pgpgout=343403pages

To turn this on, simply run:

heroku labs:enable log-runtime-metrics
heroku restart

Problem

Is there any way to find out how much memory a heroku web dyno is using? Let's say I wanna write a rake task that runs periodically and checks every dyno's memory usage. How could I do this? Thanks!

Original source