How to Migrate from Heroku to AWS

Introduction

This article aims to outline how and why to migrate your cloud infrastructure/applications from the Heroku platform to the AWS platform. The article will then go on to describe the role of Docker in this process as well as step-by-step migration guide. Lastly, this article will highlight some potential limitations and how these can be managed.

Heroku and AWS: an overview

Heroku is a cloud platform as a service (PaaS) that supports several programming languages (Java, Node.js, Scala, Clojure, Python, PHP, and Go). Notably, it was one of the first cloud-native development environments, having been developed since 2007. Heroku states that the platform ‘focuses relentlessly on apps and the developer experience around apps’. Heroku has a portfolio, or ecosystem, of cloud services which include over 200 Heroku Add-ons.

AWS (Amazon Web Services) is one of the world’s largest and most adopted cloud platforms. It is a comprehensive cloud computing platform that, unlike Heroku, is a mixture of infrastructure as a service (IaaS), PaaS, and Software as a Service (SaaS) elements. Launched in 2006, AWS was one of the first providers to offer a pay-as-you-go model which scaled to need. AWS has a large service portfolio, offering over 200 full featured services on a global scale.

Why migrate from Heroku to AWS?

Heroku’s platform has substantial limitations. These limitations have become more apparent as organisational needs have grown more complex and the required scale of applications has risen. Although Heroku was an earlier cloud computing innovator – and can still realize major benefits for startups in particular – it may not provide sufficient functionality for larger and/or more complex organisational needs. Yefim Natis, a vice president at Gartner, suggested here that Heroku struggled to adapt to industry transformations such as Kubernetes, saying that ‘I think they got frozen in time’.

Interestingly, Heroku is built on top of AWS infrastructure and provides a ready-made environment. Heroku’s platform packages a selection of services/capabilities available from AWS into easy-to-use solutions for application development. Heroku provides and manages tools such as OS and databases to allow developers to focus on functions. Put simply, Heroku’s advantage is that it provides developer friendly deployments which are easily implemented. Deployments, for example, can be achieved relatively quickly by just pushing code to a Git repository.

You should consider migrating from Heroku to AWS if:

  • You are in a growth phase and want/expect to continue growing
  • You anticipate the growth of your development team

Heroku’s major limitations are that it struggles to scale to meet complex and/or large-scale needs, provides minimal support for microservices, and is prohibitively expensive with costs increasing substantially the more you grow to scale.

When using Heroku, you are limited to the languages and environments offered. One example of this is that .NET is not supported, making Heroku unsuitable for Windows-based workloads. Additional blockers for applications built for Heroku configurations include:

  • Limited function size (max 500mb including source code and artifacts)
  • Restricted networking functionality (applications can listen to only a single port)
  • Start-up constraints (most boot in under 1 min)

Conversely, AWS offers considerable flexibility and choice. AWS has a massive service offering which encompasses a wide range of infrastructure and application-level services. Significantly, the above blockers would not constrain developers working within an AWS environment. It is AWS’s provision of IaaS, alongside PaaS and Saas offerings, that provides developers with the freedom to build what you need to any required scale. AWS’s EC2, for example, is an IaaS platform that provides bare components or instant types which allow you to build web applications etc., without constraint, in whatever software environment is most suitable.

The cost of Heroku is a major concern for organisations that are growing, plan to grow, and/or deliver large scale complex services. Heroku runs applications in containers termed dynos. Each dynos can only run one service and each additional dynos costs between $25 to $50 per month (https://www.upguard.com/blog/heroku-ec2). If many dynos are required, the cost can quickly escalate to a potentially unsustainable level.

AWS offers more cost-effective payment models. In AWS you only pay for what you use, avoiding the unnecessary costs associated with large applications that are run on Heroku. Additionally, AWS offers cost optimisation tools, plans, and services which allow you to optimise your cloud environment whilst managing your costs.

It should also be noted that AWS’s Global Infrastructure is greater than Heroku’s. Heroku’s offering, which runs on top of AWS, is divided between two common regions whereas AWS offers 26 Launched Regions and is currently investing in even more.

Using Docker for an easier migration

The use of Docker can be useful to make a migration from Heroku to AWS easier. Docker is an open-source containerisation platform. It allows developers to package an application and all its dependencies into a container environment that can run in all Linux systems. Docker creates containers that are snapshots of a system which allow you to ‘build once run anywhere’. Docker containers encase a virtual Linux filesystem allowing for its portability and the isolation of a virtual machine. Containers can be created outside of Docker, but the purpose of Docker is to increase the pace of containerisation whilst making it easier and secure.

One reason why Docker can facilitate an easier migration is that it has a much smaller resource footprint than a virtual machine. Virtual machines require an entire operating system whereas containers simply need to virtualise an application and its dependent libraries because it can use the host machine’s Linux kernel. Containers are extremely lightweight and can boot up in a matter of seconds.

Importantly, AWS is extremely compatible with containerisation technologies and microservices. Docker containers can be used to easily deploy applications on to Amazon EC2 instances. This increases the pace of migration because it requires less effort than configuring EC2 hosts to run applications. The use of a container environment manages complexity in a more practicable way.

Docker containers are runnable and can be easily deployed/managed on a container engine like Kubernetes. Kubernetes is an open-source platform for automating and managing containerised workloads/services. Kubernetes provides you with a framework to run distributed systems resiliently. It takes care of scaling and failover for your application(s) and provides deployment patterns. AWS integrates well with Kubernetes, and they also offer a Kubernetes control plane with Amazon EKS. Notably, AWS has the most customers running Kubernetes in the cloud.

Step by step migration guide

Step 1: create your Dockerfile(s)

First, Docker is used to prepare and facilitate the transfer/build of applications currently on Heroku. You must create container images of applications that will be migrated. These are known as Dockerfiles. These container images are then runnable on a container engine, e.g., Kubernetes, which can be used to manage deployment into the AWS environment.

Step 2: create resources in AWS

Before the migration can start, you need to create the necessary AWS resources. For example, you need to create the necessary instance types, e.g., the required database instance. This makes sure that the production environment contains the type of database(s) needed so that applications can be deployed, e.g., PostgreSQL, MySQL, Amazon RDS, etc.

Step 3: configure environment

You can then configure your environment and set the required environment variables. It is possible to extract the environment variables from Heroku using Heroku CLI. This allows you to export all environment variables via an .env file. Once the environment variables have been imported/set up via a web interface, you need to connect the frontend app to your backend app. This involves the creation of an environment variable alias and the connection of your backend app to your database(s).

Step 4: deployment

Once the environment has been created the migration of your applications from Heroku to AWS can be facilitated. Using Kubernetes to manage Docker containers, applications can be deployed into a live AWS environment. The application can then run with all the added benefits of the AWS service. A successful migration will have been completed.

Potential Limitations

It is necessary to state that Heroku still has benefits and that there are several possible limitations to the AWS offering. AWS offers a lot more potential and freedom to build applications, however, because of this, it can also seem complex and daunting. Compared to the simple but constrained Heroku platform, AWS can be intimidating and less user-friendly. This may also require you to onboard additional technical resources such as DevOps engineer, who can manage/navigate the environment.

Additionally, several functionalities such as Heroku’s PaaS offering, and Git-based deployments may require more time and configuration in AWS. AWS’s PaaS offering Beanstalk offers similar functionality but is still less straightforward to use than Heroku.

The potential limitations are, according to Mobilise, majorly overshadowed by the positives of AWS. For example, although AWS Beanstalk’s workflow differs, it has been found to result in savings which range from 40% to 70%. Strikingly, a survey of 200 CTOs found that 48% initially used the Heroku platform but have since moved to AWS (source).

Significantly, the AWS Partner Network (APN) is a global network of cloud technology experts that leverage AWS services for organisations and businesses around the world. This means that AWS vets technical organisations who then become AWS Consulting Partners. These partners are trained and accredited in the delivery of AWS services and can provide these services for organisations who may not have the internal resources or cloud expertise needed to harness AWS’s benefits. This includes the AWS Managed Services, which we have previously written about here.

Mobilise is an accredited AWS Consulting Partner and AWS Managed Service Provider. A managed service could eliminate the potential limitation of AWS seeming too complex or demanding for your internal resources. This is because the service would be managed end-to-end, and maintenance of the AWS environment would not be a resource drain for your in-house team.

For more information read our AWS Managed Services offering.

Enterprise and public sector trust Mobilise to securely transform their tech, teams and how they do business.

Say hello to your independence with our project enablement approach.