Skip to content
Tutorials Center
My learning

Topics

Lesson 44 of 70 ยท Load balancing, scaling and delivery

Elastic Beanstalk, App Runner and Amplify

Compare AWS's higher-level deployment services: Elastic Beanstalk, App Runner and Amplify. Learn when to pick each over EC2 or ECS, with a decision helper.

So far in this chapter you have built delivery by hand: a load balancer, an Auto Scaling group, a CDN, a container service. That is powerful, but for many teams it is more plumbing than the application deserves. AWS also offers services that sit higher up the stack. You hand over your code or container and the service builds the servers, load balancing and scaling for you.

This lesson covers three of them. Elastic Beanstalk deploys a web application onto EC2 resources it manages for you. App Runner runs a web service from a container image or a source repository with almost no setup. Amplify deploys front-end apps (and optionally a backend) straight from a Git repository. You will learn what each one does, what it gives up compared with ECS and Fargate or plain EC2, and how to choose.

None of these services can run on this site, so the commands and configuration files are read-only. The Python examples are stand-ins: a Beanstalk-style deployment-policy simulator and a decision helper that encodes the rules of thumb from this lesson. Service names and availability change over time, so check the current AWS documentation before you commit to one for a new project.

The trade-off: control versus effort

Every deployment option sits on a line. At one end you control everything (instances, networking, patching) and do all the work. At the other end you control little but the platform does the work.

flowchart LR
    EC2["EC2<br/>most control<br/>most work"] --> ECS["ECS on EC2 or Fargate"]
    ECS --> EB["Elastic Beanstalk"]
    EB --> AR["App Runner"]
    AR --> AMP["Amplify Hosting<br/>least control<br/>least work"]

Moving right, you manage less infrastructure but accept the platform's opinions about how an app is built and run.

The line is not a ranking. A simple product with a small team often gets to market faster on the right-hand side, and many teams later move left when they need something the platform does not allow. Knowing the options lets you choose on purpose.

Elastic Beanstalk

Beanstalk is the oldest of the three. You upload an application version (a zip file, a WAR, or a Docker setup), pick a platform (Node.js, Python, PHP, Java, .NET, Ruby, Go, Docker), and Beanstalk creates the resources: EC2 instances, an Auto Scaling group, a load balancer, security groups and a CloudWatch setup. The important point is that these are normal resources in your account. You can see them, and you can tune them.

The vocabulary:

  • An application is the logical project.
  • An application version is one uploaded build.
  • An environment is a running copy of a version with its resources. A web server environment serves HTTP traffic. A worker environment reads jobs from an SQS queue, which is useful for background tasks.
  • A platform branch is the managed runtime, such as a specific Python version on Amazon Linux. Beanstalk can apply managed platform updates in a maintenance window.

A typical flow with the EB command line (read-only):

Terminal
eb init shop-api --platform python-3.12 --region eu-west-1
eb create shop-api-prod --elb-type application --instance-types t3.small
eb deploy
eb status
eb logs

You customize an environment with configuration files in your repository, for example .ebextensions/ or a Procfile, and with platform hooks that run during deployment. A tiny option file might set the scaling range (read-only):

YAML
option_settings:
  aws:autoscaling:asg:
    MinSize: 2
    MaxSize: 6
  aws:elasticbeanstalk:environment:
    LoadBalancerType: application

Deployment policies

How a new version reaches the instances is configurable, and this is where Beanstalk teaches a useful general lesson about releases:

Policy How it works Trade-off
All at once Replaces every instance together Fastest, but there is downtime and a bad build hits everyone
Rolling Updates in batches, with fewer instances in service No downtime, but capacity drops during the rollout
Rolling with additional batch Starts an extra batch first to keep full capacity Safer capacity, slightly slower and costlier
Immutable Launches a fresh set of instances, then swaps Easy rollback, uses double capacity briefly
Traffic splitting Sends a percentage of traffic to the new set first A canary test with automatic rollback on bad health

For zero-risk cutovers you can also run two environments and swap their URLs, a blue/green release.

The stand-in below simulates the first four policies with a fleet of ten instances. It tracks how many instances can serve traffic at each step, so you can see the capacity trade-off in numbers.

Python Deployment policies and serving capacity

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Notice that "all at once" drops to zero serving capacity, plain rolling never goes below seven of ten, and the extra-batch and immutable policies never go below full capacity but need more instances at the peak.

When Beanstalk fits

Beanstalk fits a classic web app or API that you want on EC2 without building the Auto Scaling group and load balancer yourself, and where you want to keep access to the underlying instances. Its weaknesses are an older model than containers, a configuration system that takes time to learn, and slower, less modern tooling than newer services. For new container-first projects, many teams now choose ECS.

App Runner

App Runner is aimed at the simplest case: "I have a web service, run it." You point it at a container image in ECR or at a source repository, give it a port and some CPU and memory, and it provides an HTTPS URL, load balancing, TLS, and automatic scaling. You do not choose a VPC, subnets or an instance type to get started.

Key ideas:

  • Automatic scaling is driven by concurrency (requests in flight per instance). You set a minimum and maximum number of instances and a concurrency target. App Runner can keep a warm provisioned instance so the first request is fast, and bills a lower rate while an instance is idle.
  • Auto deployments can redeploy when you push a new image tag or commit.
  • A VPC connector lets the service reach private resources such as a database in a private subnet. Public inbound traffic still goes through App Runner's managed front door.
  • Logs and metrics go to CloudWatch automatically.

A creation call looks like this (read-only):

Terminal
aws apprunner create-service \
  --service-name shop-web \
  --source-configuration '{
    "ImageRepository": {
      "ImageIdentifier": "123456789012.dkr.ecr.eu-west-1.amazonaws.com/shop/web:1.4.2",
      "ImageRepositoryType": "ECR",
      "ImageConfiguration": { "Port": "8080" }
    },
    "AuthenticationConfiguration": { "AccessRoleArn": "arn:aws:iam::123456789012:role/AppRunnerECRAccess" }
  }' \
  --instance-configuration Cpu=1024,Memory=2048

When App Runner fits

App Runner fits stateless HTTP services, internal tools and small APIs where the team does not want to learn networking. It is limited when you need non-HTTP protocols, custom networking such as a private-only service with a load balancer you control, background workers, or fine control over placement. Before building on it, check its current status and feature list in the AWS documentation, because AWS adjusts which services it promotes to new customers over time.

Amplify

Amplify is built for front-end developers. Amplify Hosting connects to a Git repository (GitHub, GitLab, Bitbucket or CodeCommit), builds the project when you push, and publishes it behind a CDN. You get a URL per branch and a preview environment per pull request, which makes review easy. It supports static sites, single-page apps, and server-rendered frameworks such as Next.js.

The build is described in an amplify.yml file (read-only):

YAML
version: 1
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
        - npm run build
  artifacts:
    baseDirectory: dist
    files:
      - "**/*"
  cache:
    paths:
      - node_modules/**/*

Amplify also offers a code-first backend workflow: you define data models, authentication and storage in TypeScript, and Amplify provisions Cognito, AppSync or a data layer, DynamoDB and S3 for you through the CDK underneath. It is productive for small apps and prototypes, but a larger system usually grows a normal infrastructure setup beside it.

Compared with building a static site on S3 and CloudFront yourself, Amplify Hosting trades some control for a much shorter path: no bucket policies, no certificate steps, and automatic branch deployments.

Choosing between them

Ask these questions in order:

  1. Is it a front end (static or server-rendered) built from a Git repo? Start with Amplify Hosting.
  2. Is it a container that serves HTTP and needs almost no infrastructure choices? Consider App Runner.
  3. Is it a traditional web app where you want managed EC2 with access to the instances? Elastic Beanstalk works.
  4. Do you need several services, background workers, private networking, sidecars or Kubernetes? Use ECS or EKS.
  5. Do you need full OS control, special software or licensing rules? Use EC2 with an Auto Scaling group behind a load balancer.

The helper below turns those rules into a function. It is a deliberately simple stand-in for a real design discussion, but it shows how requirements push you left or right on the line.

Python A deployment-service decision helper

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Costs and lock-in

All three services charge mainly for the underlying resources or for usage, with no separate fee for the orchestration layer in Beanstalk's case. Beanstalk costs are the EC2, load balancer and storage it creates. App Runner bills for provisioned and active compute and a small build charge. Amplify Hosting bills for build minutes, storage and data served.

Lock-in is mild for all of them if your application is a plain container or a standard framework build. Keep the app itself portable (a Dockerfile, a package.json build, environment-based configuration) and moving to another service later is a configuration change, not a rewrite. See Cost Management for how to watch what these services actually spend.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What does Elastic Beanstalk create when you launch an environment?

    Beanstalk orchestrates normal resources that you can inspect and tune. That is what separates it from a fully hidden platform.
  2. 2. Which Beanstalk deployment policy keeps full serving capacity and makes rollback easy by launching a fresh set of instances?

    Immutable launches new instances in a separate group and swaps them in, so old instances remain available for quick rollback. It costs extra capacity briefly.
  3. 3. Which service is the best first choice for a React app built from a GitHub repository, with a preview URL per pull request?

    Amplify Hosting connects to Git, builds on push, serves through a CDN and creates branch and pull request previews.
  4. 4. What is a good reason to choose ECS or EKS instead of App Runner?

    App Runner targets simple HTTP services. Multi-process designs, private networking control and Kubernetes need a more flexible orchestrator.
  5. 5. How does App Runner decide when to add instances?

    App Runner scales on concurrent requests per instance, between the minimum and maximum instance counts you configure.

Summary

  • Higher-level services trade control for less operational work. Choose on purpose and keep the application portable.
  • Elastic Beanstalk builds a managed EC2 stack with environments, platform updates and several deployment policies (all at once, rolling, immutable, traffic splitting).
  • App Runner runs a simple HTTP container or source app with automatic, concurrency-based scaling and little setup.
  • Amplify Hosting builds front ends from Git with branch and pull request previews, and can provision a code-first backend.
  • Pick ECS, EKS or EC2 when you need workers, sidecars, Kubernetes, private networking control or OS access.

Next: CloudWatch Metrics, Logs and Alarms