Skip to Content
Asterrr's Handbook
2 · New solutions

AWS Elastic Beanstalk

Environment tiers, platforms, deployment policies, configuration with ebextensions, health reporting and the database and blue/green pitfalls.

Exam tasks: 2.1 (deployment strategies), 2.5, 4.3 (replatform a web application)

The decision: do you want a managed platform for a standard web application, where you upload code and AWS builds the load balancer, Auto Scaling group and monitoring, while you keep access to the instances?

Beanstalk is a platform as a service built from ordinary AWS resources. It creates an environment: an Auto Scaling group of EC2 instances, a load balancer, security groups, CloudWatch alarms and an S3 bucket for versions. You pay only for those resources.

VPCBeanstalk environmentPrivate subnetsdeployLoad balancerAuto ScalinggroupRDS, createdoutsideApplicationversion in S3
A web server environment. Beanstalk creates the load balancer and Auto Scaling group in your VPC. The database is created outside the environment.
2 tiers
Web server environments and worker environments
5 policies
All at once, rolling, rolling with additional batch, immutable, traffic splitting
CNAME swap
How Beanstalk blue/green works. It is not a deployment policy
.ebextensions
Folder of YAML or JSON configuration files in the source bundle

Tiers and platforms

Web server tierWorker tier
ReceivesHTTP requests through a load balancerMessages from an SQS queue
HowStandard web applicationA daemon reads the queue and posts each message to your app over local HTTP
Use it forWebsites and APIsBackground jobs and periodic tasks (a cron.yaml file)
  • Platforms include Java (Tomcat and SE), .NET, Node.js, PHP, Python, Ruby, Go and Docker.
  • Instances run in your VPC and you keep SSH access. Managed platform updates apply patches in a maintenance window.

Deployment policies

PolicyCapacity during deployRollback
All at onceDrops, brief outageRedeploy
RollingReduced by a batchRedeploy
Rolling with additional batchFull, an extra batch firstRedeploy
ImmutableFull, new instances in a temporary groupTerminate the new group
Traffic splittingFull, a percentage of traffic to new instancesReroute

Beanstalk offers all at once, rolling, rolling with additional batch, immutable and traffic splitting (a canary: a percentage of requests goes to a new set of instances for an evaluation period).

Blue/green in Beanstalk is not a deployment policy. You clone the environment, deploy to the clone, then swap environment URLs (a CNAME swap). Because it's DNS-based, clients with cached records keep reaching blue for a while.

Blue/green and the database

Beanstalk blue/green swaps environments. If the RDS instance was created inside the environment, it belongs to blue and gets deleted with it. Production databases should be created outside Beanstalk and passed in through configuration.

Configuration and operations

  • .ebextensions *.config files customize packages, files, commands and environment resources. Saved configurations capture environment settings to reuse. Environment properties set environment variables.
  • Enhanced health reporting reads an agent on each instance and reports application health with colors and causes. Basic health only reflects the load balancer and instance status.
  • Environment cloning copies an environment's configuration, which is the first step of a blue/green release.
  • Beanstalk uses an instance profile for instances and a service role for Beanstalk itself.
  • For anything beyond standard web applications, such as complex container networking, ECS or EKS fits better.

Scenarios

Scenario
A team runs production on Elastic Beanstalk and wants zero-downtime releases with an instant fallback. They clone the environment, deploy to the clone and swap URLs. After the first swap the application data is missing. What was the likely mistake?
Scenario
An application must process uploaded invoices in the background. Jobs are queued, may take several minutes, and the team wants the platform to manage the queue consumer and scaling. The application already runs in a Beanstalk web environment. What should they add?

Further reading

On this page