AWS Elastic Beanstalk

Learn about the important concepts of Elastic Beanstalk, environments, and deployment options.

Amazon offers us a variety of services that are used to deploy applications in the cloud. However, managing the AWS infrastructure and figuring out what services to use and how to provision them often becomes troublesome.

AWS Elastic Beanstalk solves this problem for us by deploying our applications in the AWS cloud without having to worry about the underlying architecture. We simply need to upload our application on Elastic Beanstalk, and it takes care of provisioning and managing the resources, such as EC2 instances and S3 buckets, required to deploy our application in the cloud. Elastic Beanstalk can deploy applications developed in Go, Java, .NET, Node.js, PHP, Python, and Ruby.

Press + to interact

To deploy an application using Elastic Beanstalk, first, we need to create an application and upload its source code on Elastic Beanstalk, which automatically launches an environment for us and configures the resources required to deploy our application. Once the environment is launched, we can manage it and deploy new versions of our application. We can see the flow of Elastic Beanstalk in the diagram given below:

Press + to interact
Elastic Beanstalk workflow
Elastic Beanstalk workflow

Environments in Elastic Beanstalk

In AWS Elastic Beanstalk, an environment is a collection of resources used to deploy a specific version of our application. A single application can have multiple environments, where each environment is used to host a specific version of an application. While launching an environment in Elastic Beanstalk, we first need to select one of the two environment tiers: a web server tier or a worker tier.

  • Web server tier: In the web server tier, we usually deploy web applications that receive HTTP requests from the clients, such as APIs and other interactive applications. Load balancers are launched in this tier to control and distribute incoming traffic.

  • Worker tier: The worker tier doesn’t include a load balancer and is typically used when we need to execute lengthy computational tasks, process data, or perform other backend operations that don’t require direct contact with the client. Applications deployed in a worker tier usually use SQS queues to fetch data and other requests.

Deployment in Elastic Beanstalk

AWS Elastic Beanstalk provides us with various deployment methods we can choose from depending on our application’s requirements. We must select the deployment method after careful consideration, as each method comes with its own set of tradeoffs. Following are the deployment methods Elastic Beanstalk supports:

  • All at once: This is the quickest deployment method. In this method, Elastic Beanstalk deploys a new version of our application in a new instance. This, however, can result in restarting our application server.

  • Rolling: In this method, the deployment time is increased to avoid downtime and increase availability. In this method, our application is deployed in batches.

  • Rolling with additional batch: This method takes an even longer time to deploy our application as compared to the rolling method and is used in case you want to avoid any reduced availability.

  • Immutable: In this method, Elastic Beanstalk makes sure our application is always launched on a new instance, making it a relatively slow method. One advantage of this method is that it provides a quick rollback in case our deployment fails due to any reason.

  • Traffic splitting: This is a testing deployment method used in case we want to test the health of the new version of our application by directing a part of the incoming traffic to a new version and directing rest of the traffic to the old version of our application.

  • Blue/Green: In this method, a new version of our application is deployed in a new environment. We can then swap the canonical names of the two environments to ensure our application doesn't become unavailable to the user.

Pricing in Elastic Beanstalk

There are no additional charges for using AWS Elastic Beanstalk. We are only billed on the resources created by Elastic Beanstalk to deploy our application, which includes EC2 instances, S3 buckets, DynamoDB tables, etc.

Press + to interact

One thing to keep in mind is that the main cost is typically generated by EC2 instances and load balancers.

Get hands-on with 1300+ tech skills courses.