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 |
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.
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.
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.
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.
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ễ.
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ó |