How Elastic Beanstalk's managed environments compare with Amazon ECS on Fargate for web apps and workers, covering deploys, scaling, worker tiers, databases and the configuration each one leaves to you.

Elastic Beanstalk takes an application bundle and a platform name, such as Node.js 22 or Docker, and builds the EC2 instances, Auto Scaling group and load balancer to run it. It gets awkward once the app grows a second service or a queue worker, since each becomes another environment with its own instances, and an .ebextensions change can only be tested by deploying it and reading the instance logs.
Amazon ECS is where most of those teams look next, so this guide compares the two on deploys, scaling, workers, databases and cost, and covers a way to run on ECS without taking on the infrastructure code that usually comes with it.
Beanstalk deploys an application version to an environment with a policy you choose: all at once, rolling, rolling with an additional batch, immutable or traffic splitting. Customization lives in .ebextensions config files and platform hooks that run on each instance, and managed platform updates can patch the OS and runtime during a maintenance window.
ECS deploys a new task definition revision to a service, with rolling updates by default or blue/green deployments through ECS or CodeDeploy. Everything about the container, from CPU and memory to environment variables, secrets and log configuration, is in the task definition, which you usually manage in Terraform or CDK alongside the service, load balancer and IAM roles.
A Beanstalk environment scales EC2 instances with an Auto Scaling group, and each instance runs one copy of the app. Two services means two environments, each with its own load balancer and instances, and a shared database means connecting them by hand.
ECS scales tasks, not instances, when you use Fargate. Several services share one cluster, each with its own task count, autoscaling policy and IAM role, and an Application Load Balancer can route paths to different services.
Beanstalk's worker environments run a daemon, sqsd, that reads messages from an SQS queue and POSTs each one to your app on localhost, which is convenient and also ties your worker to an HTTP contract and to Beanstalk's environment model. Periodic tasks come from a cron.yaml in the same worker environment.
On ECS a worker is a service whose code calls ReceiveMessage on SQS, processes each message, deletes it, and relies on a redrive policy and a dead-letter queue for messages that keep failing. Scheduled work goes through EventBridge Scheduler starting a task.
Beanstalk can create an RDS instance as part of the environment, and AWS recommends against it for production, since terminating the environment deletes that database. The usual pattern is an RDS instance created outside the environment and passed in through environment properties.
ECS has no database feature of its own. You create RDS separately, put it in private subnets, and allow the service's security group to connect.
Neither service has a charge of its own. Beanstalk bills the EC2 instances, load balancer and other resources it creates. ECS on Fargate bills vCPU and memory per second for each task, and ECS on EC2 bills the instances. Fargate's per-vCPU price is higher than EC2, and the gap is offset by no idle instance capacity and no instance patching.
Encore brings infrastructure from code to TypeScript and Go, so the web environment, the worker environment and the database a Beanstalk setup spreads across consoles become declarations in one codebase, and a push deploys them to ECS on Fargate, SNS with SQS, and RDS in your own AWS account. There are no .ebextensions or task definitions to write, as the AWS infrastructure docs describe.
Install the Encore CLI with the command for your system, then create the app:
Run in your terminal to get started locally.
The billing service has an encore.service.ts exporting new Service("billing") and a migration that creates an invoices table with id, customer_id, amount_cents and a nullable pdf_ready_at. The endpoint plays the web environment's part, and the subscription replaces the worker environment and its sqsd daemon:
// billing/billing.ts
import { api, APIError } from "encore.dev/api";
import { SQLDatabase } from "encore.dev/storage/sqldb";
import { Topic, Subscription } from "encore.dev/pubsub";
const db = new SQLDatabase("billing", { migrations: "./migrations" });
interface InvoiceCreated {
invoiceId: number;
}
export const invoiceCreated = new Topic<InvoiceCreated>("invoice-created", {
deliveryGuarantee: "at-least-once",
});
export const createInvoice = api(
{ expose: true, method: "POST", path: "/invoices" },
async (p: { customerId: string; amountCents: number }): Promise<{ id: number }> => {
if (!p.customerId || !Number.isInteger(p.amountCents) || p.amountCents <= 0) {
throw APIError.invalidArgument("customerId and a positive integer amountCents are required");
}
const row = await db.queryRow<{ id: number }>`
INSERT INTO invoices (customer_id, amount_cents)
VALUES (${p.customerId}, ${p.amountCents})
RETURNING id`;
await invoiceCreated.publish({ invoiceId: row!.id });
return { id: row!.id };
},
);
// Replaces the worker environment: no sqsd, no localhost POST contract.
const _ = new Subscription(invoiceCreated, "render-pdf", {
handler: async ({ invoiceId }) => {
const inv = await db.queryRow<{ customer_id: string; amount_cents: number }>`
SELECT customer_id, amount_cents FROM invoices
WHERE id = ${invoiceId} AND pdf_ready_at IS NULL`;
if (!inv) return; // already rendered by an earlier delivery
await renderPdf(invoiceId, inv.customer_id, inv.amount_cents);
await db.exec`UPDATE invoices SET pdf_ready_at = now() WHERE id = ${invoiceId}`;
},
retryPolicy: { minBackoff: "5s", maxBackoff: "2m", maxRetries: 8 },
});
async function renderPdf(id: number, customerId: string, amountCents: number): Promise<void> {
// Render and store the PDF; writing to the same key twice is harmless.
}
encore run starts Postgres and the topic locally, so the web and worker halves run together on a laptop, which a Beanstalk worker environment cannot do. On push, Encore provisions the services on ECS, the RDS database outside any environment's lifecycle, and an SNS topic with an SQS queue and dead-letter queue for the subscription, and Encore provisions an IAM role for the service. Failed messages are retried with the backoff above and then moved to the dead-letter queue, as the Pub/Sub docs describe. A coding agent asked to add a second worker adds a subscription in the same change instead of a new environment.
The database docs cover migrations, queries and transactions in more detail.
Best fit: teams moving off Elastic Beanstalk who want their web app, workers and database on ECS and RDS in their own account, declared in the code they deploy.
Beanstalk still fits a single web app on one of its platforms, maintained by a team that prefers AWS-managed instances and platform updates over containers. If the app has been running quietly for years, there is no urgent reason to move it.
Best fit: one web app on a supported platform, with few services and little need for per-service IAM.
ECS by hand gives full control over task definitions, deployment strategies and networking, at the cost of a VPC, ALB, ECR repositories, IAM roles, security groups and the Terraform or CDK to describe them. It is the standard choice for teams with platform engineers.
Best fit: teams with platform engineers who want to own every setting.
Keep Elastic Beanstalk for a single app that already runs well on it. Move to ECS on Fargate when you have several services or workers and want per-service roles and scaling. Pick Encore when you want ECS, RDS and SQS in your own AWS account without writing the task definitions and Terraform yourself.
No. Elastic Beanstalk creates and manages an environment of EC2 instances, an Auto Scaling group and a load balancer for your app, and its Docker platform runs containers on those instances. ECS is a container orchestrator: you define tasks and services and run them on Fargate or on EC2 instances you manage.
For a new containerized backend, ECS on Fargate is the more common choice: there are no instances to patch, each service gets its own IAM role and scaling policy, and several services share one cluster. Elastic Beanstalk still suits a single web app on a supported platform when the team wants AWS to manage instances and platform updates.
A Beanstalk worker environment runs a daemon, sqsd, that reads an SQS queue and POSTs each message to your app. On ECS, the worker is a service whose code reads from SQS directly, deletes messages after processing, and relies on a redrive policy to move repeated failures to a dead-letter queue.
With Encore, the services, Postgres database and queues are declared in TypeScript or Go. encore run starts them locally, and a git push provisions ECS on Fargate, RDS and SNS with SQS in your own AWS account, with Encore provisioning an IAM role for the service.
Deploy to your cloud on AWS and Google Cloud
without managing infrastructure
Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.