Heroku and your demo: It's great till it isn't

Heroku

In my previous blog post I linked to a demo application hosted on Heroku. Heroku is great, as you can use their free hosting to quickly get your demo up online using a variety of technologies. Unfortunately I ran into a few issues related to traffic spikes and bad weather. The cloud is great, until it’s not.

Background

The demo application itself is a very simple Backbone.js powered photo viewer that stores references and metadata about photos in Statigram. All of the data is stored in a single PostgreSQL table. The slides for my backbone presentation also hit the application server (written in Sinatra) which in turn hit the DB. So it’s pretty chatty over the network.

Traffic spikes

So, my blog post about Backbone.js and the accompanying slides got a lot of play on Twitter and mailing lists like JavaScript Weekly. This was awesome! However, it also meant a lot of traffic to the demo application which used a dev instance of Heroku’s PostgreSQL database offering.

The dev tier of Heroku’s PostgreSQL service is free, like their free web tier. It also turns out that the dev tier can only handle 20 connections at a time, so once people start hitting the app it quickly starts timing out and throwing errors. So if a lot of folks are running the code on the slides, and also checking out the app itself then the DB is getting a lot of connections. When I first posted the demo app, it wasn’t getting that much play and seemed to run fine. More on this in a minute.

Bad weather

This one was beyond everyone’s control. Severe electrical storms took down the Amazon Web Service data center in Virgina, which powers much of Heroku and related services. When AWS is down, Heroku effectively goes down. Shit happens. So shortly after my blog post was up, Heroku went down taking the app with it. Not the best experience for people checking it out.

Bad weather + traffic spikes

When Heroku went down due to the AWS outage I just assumed it would come back up when Heroku got everything together and brought their shared DB’s back online. Unfortunately, this coincided with the sudden popularity of the demo app. When Herkou got PostgreSQL back up, the dev DB was instantly flooded with connections and went back down. The weather trouble made it hard to tell where the problem really was, so it took a couple of days to get at the root problem (only 20 allowed connections).

Solution

Once I realized the dev tier of DB service wouldn’t cut it, I migrated to the Crane tier of service, which is a lot more robust. So far things have been cruising along fine. So if you had trouble hitting the app on Heroku, go ahead and try it now.

The downside is that a Crane instance costs $50 a month, which I consider to be a bit steep ($600 p/yr). So over the next few weeks I will work on moving things over to a MySQL DB on one of my existing Linodes. While I like Heroku quite a bit, I do find that your wallet is quickly emptied when you need to do even minimum scaling.

Moral of the story

Heroku is a great playground, and some folks use it for their startups and production apps. If like me you use it to easily deploy proof of concept apps just be ready to handle a traffic spike if you make it into Hacker News or similar. If you need a lot of DB access you may consider setting up your own MySQL server on a cheap Linode 512.

Comments