I have been using Heroku as a cloud hosting provider for the last couple of years for my personal projects, which are usually Ruby web apps, and have really grown to love the platform. Heroku is a Platform as a Service (PaaS) that sits on top of Amazon AWS. I have grown to appreciate the simplicity of using the platform via the Command Line Interface (CLI) tools provided by Heroku and it's tight integration with the Ruby toolchain and Git, which I use almost exclusively these days for Software Configuration Management (SCM). The support for Ruby and the ease of setting up my deployment and installation tasks has been very simple because Heroku uses the standard tooling that I was already using to do Ruby development. Deployment to Heroku was as easy as performing a push with Git.
Heroku Node.js Deployment Steps:
$ git init
$ git add .
$ git commit -m "initial commit"
$ heroku create my-first-node-api
$ git push heroku master
While doing my research and development of this API, I ended up reading quite a bit on Amazon Elastic Beanstalk. It appeared that quite a few people have written similar Node.js REST APIs and deployed them directly on to Amazon EC2 instances using Amazon's new Elastic Beanstalk tooling. This piqued my curiosity, and I decided that I should compare the configuration, deployment, and cost differences between Elastic Beanstalk and Heroku.
- Ease of Create a Deployment Target
- Ease of Deployment
- Git Integration
- External Service Integration (DB Tier, Other Web APIs, Cache Providers etc.)
Amazon's Elastic Beanstalk tooling integrates directly with their EC2 instances in order to provide a competing experience to Heroku and other PaaS providers. The basics of the Elastic Beanstalk tooling are a CLI tool and Git integration so that pushing out live code and configuration can all be handled with out having to login to the EC2 Web Console or SSHing into your EC2 instance. The creation of new server instances to deploy to and all other configuration can be handled using the CLI tool. This addresses my first 3 criteria, and the experience is actually very similar to the Heroku workflow I described above, so there isn't a clear winner yet. To follow along you can deploy the "hello world" app from above after you have installed the Elastic Beanstalk CLI tools following the below steps. As you can see pushing out live code is just as easy as the Heroku steps from above.
Elastic Beanstalk Node.js Deployment Steps:
$ git init
$ git add .
$ git commit -m "initial commit"
$ eb init my-first-node-api
My fourth criterion is about integration with external services. Obviously, if your application doesn't require any new external services or is only interacting with other existing services that you own then this question might not matter to you at all. Heroku has a lot of baked in add-ons that allow you to setup and integrate with a new database tier, caching provider, or reporting service that is hosted by one of these add-on providers. This feature is accessible from Heroku's CLI and makes it very easy to setup the other pieces that may be needed by your application. For a full list of available add-ons checkout the add-on repository here. Elastic Beanstalk some is weak here, but if you are using Amazon's Databases or other services you can access and configure those via the Elastic Beanstalk CLI. This is a clear advantage for Heroku if you need one of the service add-ons that are offered.
Finally, let's talk about cost. If you look at Heroku's Pricing and Amazon's Elastic Beanstalk Pricing, you can do a quick comparison of each service's cheapest instance. Free instances at Amazon are limited to 1 year after account creation vs. unlimited at Heroku so we will not be comparing those. At the time of writing the monthly costs for the next cheapest options are $34.50 at Heroku and $35.115 at Amazon. Comparing features Heroku's instance has more dedicated RAM than the similarly priced Elastic Beanstalk instance as well as having 2 CPUs vs 1 at Amazon. This would appear to be a big win on the Heroku side but, it is important to note that the CPU instances at Heroku are shared and the CPU at Amazon is dedicated entirely to your instance. Both Heroku and Elastic Beanstalk are layers on top of Amazon EC2 instances so at the core you will get a similar level of service in relation to the hardware and network layer that is underneath your application.
If you go the Amazon Elastic Beanstalk route you will be setting up your application on an actual EC2 instance that you have complete control over, so you will be able to remote into that instance if you like and install other software that you may need. Heroku's application containers do not afford you this privilege, so if there was any custom software that you needed that is not supported by Heroku then you would be out of luck. Heroku does support most of the major software you would need for making web applications on any of the frameworks that it supports, but this is still something worth considering when talking about cost. Additionally, Amazon provides an out of the box way to configure auto-scaling of it's EC2 instances, meaning if there is some level of traffic spike it will automatically allocate new instances to run and serve requests. This functionality is not supported by the default Heroku service, but there appear to be a few custom solutions that have been proposed by Heroku users online. Finally, it should be noted that the Amazon price is a total of the estimated variable bandwidth and data that your application would use so the price may be slightly lower or higher per month.
|Ease of Creating a Deployment Target||TIE||TIE|
|Ease of Deployment||TIE||TIE|
|External Service Integration||WIN*||LOSS|
Looking over all of this data, it seems that for the purposes of the prototype web application that I was building Heroku was still the best option. It provided free hosting and access to all of the libraries that I needed, and if this system did end up needing to be elevated to production I could easily upgrade to the cheapest Heroku instance. However, in the future when choosing which PaaS to host a system that I know will be going into a full production environment, I think that Elastic Beanstalk is the clear winner providing all of the functionality that is great about Heroku, with the exception of Heroku's add-on platform, and with the additional ability to fully control my instance at a price that is easily comparable to that of Heroku.