Xoxoftware - XOXO Creative Studio | Web & Mobile App Development | Fred Cheung | Hong Kong
AWSCompute

AWS Elastic Beanstalk

Platform as a Service (PaaS) — deploy and manage web applications without infrastructure complexity, covering deployment policies, environment tiers, and .ebextensions.

Overview

AWS Elastic Beanstalk is a Platform as a Service (PaaS) — upload application code and Beanstalk automatically handles provisioning, load balancing, auto scaling, and health monitoring of the underlying infrastructure.

Beanstalk supports multiple platforms (Java, .NET, Node.js, Python, Ruby, Go, PHP, Docker) and deploys applications on familiar AWS resources (EC2, ALB, ASG, RDS, S3) while retaining full control over those resources when needed.


Core Concepts

ConceptDescription
ApplicationTop-level container — a logical collection of environments, versions, and configurations
EnvironmentA running instance of an application version on AWS infrastructure (web server or worker)
Application VersionA labelled iteration of deployable code, stored as a ZIP/WAR in S3
Environment TierWeb Server (handles HTTP via ALB) or Worker (processes jobs from SQS)
PlatformThe OS, runtime, web server, and Beanstalk components (e.g., Python 3.11 on Amazon Linux 2023)
ConfigurationSettings controlling instance type, scaling, load balancer, environment variables, etc.
.ebextensionsYAML/JSON config files in .ebextensions/ that customise the environment at deploy time
Saved ConfigurationReusable named snapshot of environment settings

Environment Tiers

TierPurposeComponents
Web ServerServe HTTP requests from end usersALB/NLB + ASG + EC2 instances
WorkerProcess background tasks from a queueSQS queue + ASG + EC2 instances (daemon)
Web Server Tier                    Worker Tier
┌─────────────┐                   ┌─────────────┐
│     ALB      │                   │   SQS Queue  │
└──────┬──────┘                   └──────┬──────┘
       │                                 │
┌──────▼──────┐                   ┌──────▼──────┐
│ EC2 (ASG)    │                   │ EC2 (ASG)    │
│ App Server   │                   │ Worker Daemon │
└─────────────┘                   └─────────────┘

SAA/SAP Tip: Use the Worker tier to decouple background processing. A web server environment posts messages to an SQS queue; the worker environment picks them up and processes them. This pattern is a common exam topic for decoupled architectures.


Deployment Policies

PolicyDowntimeRollback SpeedDescription
All at OnceYesRedeployDeploys to all instances simultaneously — fastest but causes downtime
RollingNo*RedeployDeploys in batches; reduces capacity during deployment
Rolling with Additional BatchNoRedeployLaunches extra instances first to maintain full capacity during rollout
ImmutableNoFast (terminate)Deploys to a fresh ASG; swaps in on success; safest for production
Traffic SplittingNoFast (reroute)Canary-style — sends a percentage of traffic to new version, then shifts
Blue/Green (manual)NoSwap URLsTwo separate environments; swap CNAMEs after validation

Exam Trap: "Immutable" and "Blue/Green" are different deployments. Immutable creates new instances within the same environment. Blue/Green creates an entirely new environment and swaps CNAMEs — it is not a built-in policy but a manual strategy.


.ebextensions

Configuration files placed in the .ebextensions/ directory at the application root customise the environment during deployment.

  • File format: YAML or JSON with .config extension (e.g., .ebextensions/01-packages.config)
  • Processed in alphabetical order by filename
  • Can install packages, create files, run commands, configure services, and set option settings
# .ebextensions/01-packages.config
packages:
  yum:
    git: []

option_settings:
  aws:elasticbeanstalk:application:environment:
    NODE_ENV: production

container_commands:
  01_migrate:
    command: "npm run migrate"
    leader_only: true

Key sections: packages, sources, files, commands, container_commands, option_settings, services.

leader_only: true ensures a command runs on only one instance during deployment — useful for database migrations.


Beanstalk with RDS

ApproachDescriptionRecommendation
RDS inside environmentRDS created and managed by Beanstalk; tied to environment lifecycleDevelopment/testing only
RDS outside environmentRDS created independently; connection string via env variablesProduction — decoupled lifecycle

Exam Trap: If RDS is created inside a Beanstalk environment, deleting the environment also deletes the database. For production, always create RDS independently and pass the endpoint via environment variables.


Common Use Cases

  • Rapid prototyping — Deploy a web application in minutes without configuring infrastructure manually.
  • Standard web applications — Run Java, .NET, or Node.js apps with auto scaling and health monitoring out of the box.
  • Decoupled processing — Web server tier + worker tier pattern for handling async tasks (image processing, email sending).
  • Docker deployments — Run single-container or multi-container Docker applications on Beanstalk's Docker platform.
  • Development/staging environments — Quickly spin up isolated environments for testing.

SAA/SAP Exam Tips

SAA/SAP Tip: Elastic Beanstalk provides the easiest path to deploy a web application on AWS with full control retained over underlying resources. If the question mentions "developer productivity" or "minimal infrastructure management" for a standard web app, Beanstalk is the likely answer.

Exam Trap: Beanstalk itself is free — charges apply only for the underlying resources (EC2, ALB, RDS, etc.) that it provisions. This is a key difference from higher-abstraction services like App Runner.

SAA/SAP Tip: For zero-downtime deployments, choose Rolling with Additional Batch or Immutable. For the safest production deployment with fast rollback, Immutable is preferred.


Cross-Cloud Equivalents

ProviderService / SolutionNotes
AWSAWS Elastic BeanstalkBaseline
AzureAzure App ServiceSimilar PaaS; more opinionated platform choices
GCPGoogle App EngineStandard (sandboxed) and Flexible (Docker) modes
On-PremisesHeroku, Dokku, Cloud FoundryPaaS platforms for self-hosted environments

Pricing Model

DimensionUnitNotes
Elastic BeanstalkFreeNo charge for the service itself
EC2 instancesPer useStandard pricing (On-Demand, Reserved, Spot)
Load balancersPer hour + LCUALB/NLB pricing applies
RDS (if provisioned)Per useStandard RDS pricing
S3 (app versions)GB-monthApplication version bundles stored in S3

Built by Fred Cheung @CookedRicer · Powered by Fumadocs & Github Copilot

On this page