This website is written in Ruby using the Sinatra framework and hosted with Passenger / Nginx on the Raspberry Pi ( temporarily not on a Pi! ) assisted by Cloudflare and a dash of jsDelivr

Heroku Control Panel

After attending the local Norwich Ruby user group meeting and enjoying some healthy discussion about hosting-on-Heroku and the Amazon Elastic Beanstalk, I was inspired by the phrase "turn down the dynos." Since TechWeek Europe are still calling for your office gadget ideas I thought I could throw together another hair-brained scheme and see if they bite.

A "Dyno" in the context of Heroku is a single web worker process. More of these mean your web application can handle more traffic. But they also mean it's going to cost more. When it comes to "Worker Dynos", which are back-end worker processes which handle processing jobs that aren't related directly to a client request, you might often want to scale these up in order to get a job done quickly, and then back down when you're done to avoid prohibitive ongoing costs.

Heroku has a command-line tool, and a command-line tool can be scripted. It also has a public API, although that's severely rate-limited. So the sensible choice is to create a physical control panel, from a Pi or Arduino, a collection of linear potentiometers and some bargraph LEDs, and hook it up to a computer with a basic interface script to the cli binary.

This would be a great little project for a hackday collaboration. I envision between 4 and 10 pots, or "dials" if you will, each with one or two bargraph LEDs. APIs would be tapped into to show both the current number of running dynos, and the "saturation" ( or amount of web traffic/load divided by the amount of dynos, or something useful like that ) so that you can see at a glance when something should be dialled up or down.

Obviously this has little practical use, except in the case of worker Dynos where you might need to remember to scale them back down after a period of time. We could slap in a 7-segment display and an alarm buzzer for that.

RS Online have pretty much all the components required, although finding them is an excercise in futility if you don't know exactly what you're looking for:

This is a nice little project that I'm confident has a half-decent chance of being completed and well documented. Not only will it teach the people putting it together ( hopefully more than just me ) about interfacing various components with a computer, but it will also prompt an exploration of Heroku and of various statistics monitoring APIs. In the long term it could be expanded to a complete status control panel... it might actually be genuinely useful.

It's also easy to prototype, we can string together some components and software on a table to see how things might work. At a basic level I envision the Arduino handling all the direct driving of at least the analogue components, although there are a plethora of Raspberry Pi boards out there which would do just as well. The Arduino would then communicate with the Pi over logic-level-shifted serial, or USB serial and the Pi would be responsible for digesting the various analogue control commands into Heroku CLI actions.

For status information, a Ruby script could easily tap into the various available traffic, log and status APIs and light up LEDs, bargraphs or even LCD displays with information on the current status of various sites. Perhaps a more flexible way would be to emunerate all available applications on Heroku via the cli and use a handful of knobs, bargraphs and 7 segment displays or 5x7 dot matrix displays which can each be switched between sites on the fly. This way you could control all of your applications from one control panel.

« Back to index Posted on 2013-06-20 by