Ace Cloud Interviews
Home/AWS Tutorial/Elastic Beanstalk

AWS Compute

Elastic Beanstalk

PaaS for deploying and scaling web applications without managing servers

AWS Elastic Beanstalk is a Platform-as-a-Service (PaaS) that handles the undifferentiated heavy lifting of deployment infrastructure. You upload your application code, and Beanstalk automatically provisions EC2 instances, load balancers, Auto Scaling groups, RDS databases, and CloudWatch alarms. You retain full control over the underlying resources.

Core Concepts

ComponentDescription
ApplicationA logical collection of Elastic Beanstalk components - like a folder. Not the code itself.
Application VersionA specific labeled iteration of deployable code, stored in S3. You can deploy any version to any environment.
EnvironmentA running collection of AWS resources (EC2, ELB, ASG) running one application version at a time.
Environment TierWeb server tier (serves HTTP requests via ELB) or Worker tier (processes jobs from an SQS queue).
PlatformThe OS + runtime + web server combination. e.g., "64bit Amazon Linux 2 v5.x running Node.js 18".
Saved ConfigurationA named snapshot of environment settings that can be applied to new or existing environments.

Beanstalk supports these application platforms: Node.js, Python, Ruby, PHP, Go, Java (Tomcat or SE), .NET on Linux, .NET on Windows, and Docker (single or multi-container).

Deployment Policies

How Beanstalk deploys new application versions to instances affects downtime, speed, and rollback capability. This is a common interview question.

PolicyDowntimeDeployment SpeedRollbackNotes
All at onceYesFastestManual redeploymentDeploy to all instances simultaneously. Only for dev/test.
RollingNoSlowManual redeploymentUpdates a batch at a time. Some instances serve old version during deploy.
Rolling with additional batchNoSlowManual redeploymentLaunches extra instances first so capacity is maintained throughout.
ImmutableNoSlowestFast (terminate new ASG)Launches a new ASG with new instances, then swaps. Safest for production.
Traffic splittingNoSlowFast (redirect traffic)Canary-style - send a % of traffic to new instances, monitor, then shift fully.
Blue/Green (swap URLs)NoFastInstant (swap URLs back)Two separate environments. Swap CNAME. Not built-in - requires manual steps.
💡

For zero-downtime production deployments with the fastest safe rollback, use Immutable or Blue/Green. Immutable is built-in; Blue/Green requires managing two environments.

Customizing the Environment

  • .ebextensions/ directory: place YAML/JSON config files in your deployment bundle to customize EC2 instances (install packages, run commands, set environment variables, create files, configure the load balancer)
  • .platform/ hooks: shell scripts that run at specific lifecycle events (prebuild, predeploy, postdeploy) for deeper OS-level customization
  • Environment variables: set at the environment level in the console or EB CLI - available as process env variables in your code
  • Managed updates: Beanstalk can automatically apply platform updates (OS patches, runtime minor versions) during a weekly maintenance window
  • Enhanced health reporting: detailed health metrics per instance and environment, color-coded (Green/Yellow/Orange/Red) with root cause hints
yaml
# .ebextensions/install-deps.config
packages:
  yum:
    git: []
    jq: []

commands:
  01_set_timezone:
    command: "ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime"

container_commands:
  01_migrate:
    command: "python manage.py migrate"
    leader_only: true

EB CLI Workflow

bash
# Initialize Beanstalk in your project
eb init my-app --platform "python-3.11" --region ap-south-1

# Create an environment and deploy
eb create my-app-prod --instance-type t3.small --single

# Deploy latest code to existing environment
eb deploy my-app-prod

# SSH into an instance
eb ssh

# View logs
eb logs

# Swap environment URLs (Blue/Green)
eb swap my-app-blue --destination_name my-app-green
🎯

Interview Focus Points

  • 1Deployment policies - differences between Immutable, Rolling, and Blue/Green
  • 2Web server tier vs Worker tier - when would you use a worker tier?
  • 3.ebextensions - what can you configure and when would you use it?
  • 4How Beanstalk differs from ECS and when you would choose one over the other
  • 5Managed updates - what gets updated and how to avoid unexpected downtime
  • 6How to perform a zero-downtime deployment with instant rollback capability