AWS Elastic Beanstalk

A developer-centric wrapper over the stack you already know — EC2, ASG, ELB, RDS — provisioned and re-deployed from one view. You hand over code; Beanstalk owns the OS, capacity and deploy mechanics but never hides the knobs.

Một lớp bọc thiên về developer trên đúng stack bạn đã biết — EC2, ASG, ELB, RDS — provision và re-deploy từ một chỗ. Bạn giao code; Beanstalk lo OS, capacity và cơ chế deploy nhưng không giấu đi các nút chỉnh.

Reach for it / not the right toolKhi nào dùng / khi nào không

Reach for BeanstalkChọn Beanstalk

  • "Replatform" from on-prem to cloud — lift a web app onto managed EC2 without re-architecting."Replatform" từ on-prem lên cloud — đưa web app lên EC2 managed mà không phải viết lại kiến trúc.
  • A team that wants EC2/ASG/ELB but doesn't want to wire it by hand or maintain the OS.Team muốn EC2/ASG/ELB nhưng không muốn tự đấu dây hay bảo trì OS.
  • Standard runtime (Node/Java/Python/.NET/Docker) that fits a supported platform.Runtime chuẩn (Node/Java/Python/.NET/Docker) khớp platform hỗ trợ.

Not the right toolKhông phải chỗ dùng

  • Deploying to instances Beanstalk doesn't manage → use CodeDeploy (EC2/ASG/ECS/Lambda).Deploy lên instance Beanstalk không quản → dùng CodeDeploy (EC2/ASG/ECS/Lambda).
  • Full serverless / event-driven → Lambda; container orchestration → ECS · EKS.Serverless / event-driven hoàn toàn → Lambda; orchestrate container → ECS · EKS.
  • You want to describe the whole stack as code across services → CloudFormation / IaC, not a wrapper.Muốn mô tả cả stack bằng code across service → CloudFormation / IaC, không phải một lớp bọc.

Who owns whatAi sở hữu cái gì

The whole point: the responsibility line sits just above your code. Everything below it is Beanstalk's job — but every knob stays exposed. Điểm cốt lõi: ranh giới trách nhiệm nằm ngay trên code của bạn. Mọi thứ dưới nó là việc của Beanstalk — nhưng mọi nút chỉnh vẫn để lộ ra.

YouBạn Beanstalk
Application codeCode ứng dụng ✅ —
Instance config / OSConfig instance / OS — ✅
Capacity (ASG, ELB)Capacity (ASG, ELB) — ✅
Deployment strategyChiến lược deploy ConfigureCấu hình PerformThực thi
Read the differenceĐọc kỹ khác biệt You choose the deployment strategy; Beanstalk runs it. Instance/OS config and capacity are handled for you, yet you keep full control over the configuration of each component — Beanstalk manages, it doesn't lock you out. Bạn chọn chiến lược deploy; Beanstalk chạy nó. Config instance/OS và capacity được lo giúp, nhưng bạn vẫn giữ toàn quyền cấu hình từng component — Beanstalk quản lý chứ không khoá bạn ra ngoài.

Supported platformsPlatform hỗ trợ

Standard language runtimes plus several Docker flavours. If your app fits one of these, Beanstalk is the fast "replatform" path. Các runtime ngôn ngữ chuẩn cộng vài kiểu Docker. Nếu app khớp một trong số này, Beanstalk là đường "replatform" nhanh.

Go
Java SE+ Java with Tomcat+ Java với Tomcat
.NETWindows Server + IISWindows Server + IIS
Node.js
PHP
Python
Ruby
Packer Builder
Dockersingle · multi-container · preconfiguredsingle · multi-container · preconfigured

Three environment modelsBa mô hình môi trường

Same service, three shapes. Pick by workload: one box for dev, load-balanced fleet for prod web, queue-fed fleet for workers. Cùng một service, ba hình dáng. Chọn theo workload: một box cho dev, fleet có load balancer cho web prod, fleet ăn queue cho worker.

The three Beanstalk architecture models side by side — Single Instance with an Elastic IP and RDS master; a load-balanced ASG spanning two AZs with an ALB and RDS master plus standby; and a worker tier where an SQS queue feeds an EC2 Auto Scaling Group Single Instance great for dev Availability Zone Elastic IP EC2 Instance RDS Master High availability · LB + ASG great for prod ALB Availability Zone 1 Availability Zone 2 Auto Scaling Group EC2 Instance EC2 Instance RDS Master RDS Standby Worker tier ASG only PUT SQS Queue Auto Scaling Group EC2 EC2 SQS + EC2

Single Instance → one EC2 behind an Elastic IP (dev). LB + ASG → an ALB fronts an Auto Scaling Group across two AZs with an RDS master + standby (prod web). Worker → a queue feeds an EC2 ASG that drains it (non-web / background jobs).

Single Instance → một EC2 sau Elastic IP (dev). LB + ASG → ALB đứng trước Auto Scaling Group across hai AZ với RDS master + standby (web prod). Worker → queue đẩy vào EC2 ASG để rút queue (non-web / job nền).

Web server vs worker environmentWeb server vs worker environment

If a task is long to complete, offload it from the web tier to a dedicated worker tier — decoupling into two tiers is the common pattern. Nếu một task chạy lâu, đẩy nó khỏi web tier sang worker tier riêng — tách thành hai tier là pattern phổ biến.

A web tier of ELB plus EC2 receives requests and PUTs long-running work onto an SQS queue, which a separate worker tier of EC2 in an Auto Scaling Group consumes Web Tier = ELB + EC2 ALB EC2 ASG requests SQS queue PUT Worker Tier = SQS + EC2 EC2 ASG

Web tier handles requests and PUTs work onto SQS; the worker tier's EC2 ASG pulls from the queue. Examples: processing a video, generating a zip. Periodic jobs are defined in a cron.yaml file.

Web tier xử lý request và PUT việc lên SQS; EC2 ASG của worker tier rút khỏi queue. Ví dụ: xử lý video, tạo file zip. Task định kỳ khai báo trong file cron.yaml.

Exam tellDấu hiệu trong đề "Long-running / async task" + "don't block the web request" + Beanstalk → worker environment, fed by SQS. "Run something every night" inside a Beanstalk worker → cron.yaml. "Task chạy lâu / async" + "không chặn web request" + Beanstalk → worker environment, ăn từ SQS. "Chạy gì đó mỗi đêm" trong worker Beanstalk → cron.yaml.

Blue / green deploymentDeploy blue / green

Not a direct Beanstalk feature — a pattern. Stand up a new "stage" (green) env with v2, validate it independently, then swap. Zero downtime, easy rollback. Không phải feature trực tiếp của Beanstalk — một pattern. Dựng env "stage" (green) mới với v2, validate độc lập, rồi swap. Không downtime, rollback dễ.

Blue/green with Beanstalk — a blue environment running v1 and a green stage environment running v2, both fronted by Route 53 weighted routing sending 90 percent of web traffic to blue and 10 percent to green during validation Environment "blue" v1 v1 v1 Environment "green" (stage) v2 v2 v2 Route 53 weighted web traffic 90% 10%

Deploy v2 to a fresh green env; use Route 53 weighted policies to send a little traffic there and validate. When happy, "swap URLs" (DNS swap) to promote green — or roll back to blue if issues.

Deploy v2 lên env green mới; dùng Route 53 weighted để đẩy chút traffic sang đó và validate. Khi ổn, "swap URLs" (đổi DNS) để promote green — hoặc rollback về blue nếu có lỗi.

  • Zero downtime + release facility — the green env is validated in isolation before it ever takes full traffic. Không downtime + cơ chế release — env green được validate riêng trước khi nhận full traffic.
  • Route 53 weighted redirects "a little bit" of traffic to the stage env — canary-style validation. Route 53 weighted chuyển "một chút" traffic sang env stage — validate kiểu canary.
  • Swap URLs (DNS swap) is the promote step — done inside Beanstalk once the stage env passes. Swap URLs (đổi DNS) là bước promote — làm ngay trong Beanstalk khi env stage đạt.

Beanstalk vs CodeDeployBeanstalk vs CodeDeploy

The moment the instances aren't managed by Beanstalk, Beanstalk is out. To roll code onto arbitrary fleets, reach for CodeDeploy (or open-source tooling — Ansible, Terraform, Chef, Puppet). Ngay khi các instance không do Beanstalk quản, Beanstalk hết cửa. Để đẩy code lên fleet bất kỳ, dùng CodeDeploy (hoặc tool open-source — Ansible, Terraform, Chef, Puppet).

Elastic Beanstalk AWS CodeDeploy
Owns the instances?Sở hữu instance? Yes — provisions the whole envCó — provision cả env No — deploys onto instances you already runKhông — deploy lên instance bạn đã chạy
Deploys toDeploy tới Its own managed EC2 / ASGEC2 / ASG do nó quản EC2 · ASG · ECS · Lambda
Use whenDùng khi Replatform a web app fast, one viewReplatform web app nhanh, một view Automate deploys to many existing EC2Tự động deploy lên nhiều EC2 sẵn có