A Heroku fans’ foray into Elastic Beanstalk
I consider myself a fan of Heroku.
And by that I mean I’ve bought into the whole PaaS thing that Heroku provides and I use it for 90% of my projects. I’ll even go ahead and say I’ve done a fair bit of evangelising and brought some of my clients to Heroku as well. It’s been great so far. I like the fact that I don’t have to maintain servers myself and do DevOps — which takes my focus away from rapid prototyping.
Enter Elastic Beanstalk.
I consider Elastic Beanstalk to be AWSs’ answer to Heroku. It comes with the
promise that you install a CLI, do a
deploy, and then your app
would go through a automated deployment pipeline that would spin up EC2
instances and load balancers and deploy the app.
For me at least, this only works in theory.
AWS EB has so many moving parts underneath that are open to customisation, that
it took me forever to figure out what was going wrong with a simple Node.js
application compiled with babel, post-deployment. First it was permission
problems in the
/tmp/deployment/ directory that prevented it from creating the
npm-depbug.log when something wrong went with the build. And then it was the
painfully long deployment times on t1.micro. And add to that the fact that there
are dozens of people with the same problems that I did, offering “unofficial
fixes provided by AWS support”, in the AWS dev forums.
I’m pretty sure a simple express-based application deploys fine without a hitch. But even an app as basic as mine with a non-standard setup — and by that I mean a build step — was failing. Maybe that wasn’t an intended use case for the default scripts that run on Beanstalk.
In the end, the collection of things that ended up working was borrowed from better-faster-elastic-beanstalk — which has a drop-in replacement for default AWS EB scripts. (Much like a custom Heroku buildpack) If you’re trying to deploy a Node.js app on Beanstalk, I’d highly recommend going through their repo and reading the scripts — so you can customise them as needed, and learn how AWS EB treats your deployment payload under the hood.
On the bright side, it was refreshing to see all the things that I could control within AWS EB with just a configuration. Complete control over SSH and z.sh on shell? Done. Automated Load Balancing configuration based on CPU usage? Done. Running arbitrary shells scripts throughout deployment and as cron jobs? You bet.
So, I get the appeal of Elastic Beanstalk. Rather than being stuck with Heorkus’ platform, you can fine tune anything you want in your app and integrate other AWS services with such ease. But for the vast majority of instances, Beanstalk doesn’t even come close to the ease of deployment that Heroku offers, at least for now. And for the small minority of instances that require intense scaling and fine-tuning, Heroku doesn’t even come close to the versatility Elastic Beanstalk offers.