What's The Best Way To Deploy Rails Web Applications on AWS?

Today, you are spoilt for choice. You have enough, easy to follow options to get your Rails application running on Amazon Web Services in no time. If you found it hard previously to deploy your Rails application since you couldn't plop the code like in PHP and run it on Apache, now Phusion Passenger makes it possible. Even so, you do not want to miss out on the benefits an automated deployment tool comes with, unless you have a very simple application and all you’re looking for is code updates and maybe Rails migrations. Benefits of an automated deployment tool include improved productivity, visibility, auditability and a method, less prone to errors.

The best way?

Again, you’ll hear this a lot in most blogs which recommend a particular method without knowledge of your context, this is a blanket recommendation. Take it with a pinch of salt or rather take it with due consideration to your priorities and your user’s needs.

Capistrano is a quite popular amongst the Rails community, with good reason. It works for all the usual cases where you have to deploy your web application to your servers. Capistrano is a simple tool. You begin by copying code from your Git to your server, then performing a bunch of deploy functions like restarting the web server, renaming files, busting cache, running database migrations and more. Capistrano also allows multi-server, multi-stage deploys.

Now recently, Amazon Web Services introduced the Elastic Beanstalk for the deployment and scaling of Rails web applications in their ecosystem. The Elastic Beanstalk is an easy to use service under Platform-as-a-service(PaaS). All you have to do is upload the code, and the Beanstalk handles the deployment, from capacity provisioning, load balancing, auto-scaling to health monitoring, and you still have control over the resources powering your application. You can access these resources anytime. Furthermore, you only pay for the AWS resources needed to power and run your application. Beanstalk will also help provision all the necessary AWS resources for you. In a nutshell, EB gives you a powerful CLI similar in functionality to Heroku’s, different deployment strategies like the blue-green deployment or a rolling update and a customizable monitoring dashboard.

With ECS you do not have many of these options. If you choose to deploy using Docker Containers, Elastic Beanstalk will run over ECS. ECS is meant to let you customize your software stack. It efficiently schedules Docker containers on a cluster of EC2 machines. The Docker containers are also a relatively new feature of AWS.

It’s still not fair to compare Capistrano and Beanstalk as they are intended to serve different purposes and come with their benefits. Even so, why bother writing code to deal with infrastructure in Capistrano’s case if Beanstalk does the same job for you. It also takes away a lot of the pain which comes with scaling up a web application. For most cases, the Elastic Beanstalk is easier to maintain in the longer run.

Need help with product design or development?

Our product development experts are eager to learn more about your project and deliver an experience your customers and stakeholders love.

Read more