Random thoughts of a warped mind…

August 14, 2012

Inside Heroku

Filed under: EC2,Heroku,Ruby,Virtualization — Srinivas @ 16:29

I’ve been playing around with Heroku for a while and they mention their unit of execution to be a “Dyno” – This is their concept of a container for a process, be it a web process or a background worker. Just for kicks I wanted to what kind of hardware this ultimately runs on (considering that Heroku runs out of Amazon EC2 after all… do they provision a new instance or do they give you a slice of an existing one and all that…).

Thats where Ohai steps in – Ohai is a ruby gem that was built by Opscode(Love ya guys! Brilliant work!!! :-) ) to run as part of Chef and its primary function is to build a nodes attributes object (disks, memory, modules, cloud instance values specific to EC2/baremetal/other_cloud_provider etc). Ohai can be used independent of Chef too and is a handy tool to grabbing system attributes at one-shot.

Ohai also ships with a standalone executable (“ohai”) that can be run on any system with this gem installed to generate a JSON object containing most of the details of the system (hardware/OS info etc).

I spun up a simple Sinatra app on Heroku to use Ohai to get a JSON object with the system info – This app is available from http://inside-heroku.onepwr.org .

Upon accessing the Heroku app, I realized that running Ohai on Heroku does’nt get much info – probably because its not run as root and also because Heroku somehow limits the amount of info that can be obtained(which sort of makes sense in a way). I am keen on seeing for myself what Heroku actually provides within a Dyno… If you know of a way to do that, let me know :-)

UPDATE 20120815 – I thought the Heroku “supplied” Ohai was not set to show all info so I would push in my own version from my dev system. So I gem unpacked ohai (v 6.14.0) into my local lib folder on my dev machine and updated web.rb to include that in the LOAD_PATH, added some additional gems that Ohai needs (mxlib-config/log/cli, systemu and yajl-ruby) into my Gemfile and pushed new version of app to Heroku. Still cant see any additional info :-(

UPDATE 20120824 – I got some time today to revisit this. Ohai does’nt detect cloud attributes properly if the host is in a VPC – Ohai 6.1.4 provides the ability to provide hints to ohai in the form of empty files ec2.json in folder /etc/chef/ohai/hints (or rackspace specific files etc). These files are currently checked only for existence and contents unused (although that may change in the future). So I figured, what if Herokus dynos run in a VPC which may explain why Ohai could not get the cloud attributes… To cut a long story short, I modified the local ohai gem I was pushing to sources hints from a local folder in my app code base as its hints folder (corresponds to Ohai::Config hints_path). Still no cloud attributes, damn! Curious and Curiouser…I have’nt pushed the updated code to github yet, may be later…

References -

Ohai – http://wiki.opscode.com/display/chef/Ohai

Dynos & Dyno Manifold – https://devcenter.heroku.com/articles/dynos

Source for the inside-heroku app at Github – https://github.com/srinivasmohan/InsideHeroku

Inside-Heroku app at Heroku – http://inside-heroku.onepwr.org

Powered by WordPress