Elastic Beanstalk (EB)
Introduction
Elastic Beanstalk is a platform-as-a-service (PaaS) for deploying server applications. It handles the EC2 deployment, load balancing, and autoscaling all in one. This shifts focus away from system management to make it easy for developers to reliably deploy changes to code.
Environments
- The X represents the iteration, as to update to major platform versions, it needs an entirely new environment
- resn-production-X
- This is the user-facing “web server” environment for the Django project
- It is deployed to https://old.resn.org.au/
- It runs on Python 3.8 on the same ap-southeast-2 VPC as the RDS database
- resn-worker-X
- This is the periodic “worker” environment for the Django project
- It connects to an SQS queue for asynchronous background tasks (mainly emails)
- It runs on Python 3.8 on the same ap-southeast-2 VPC as the RDS database
- resn-metabase-X
- This is the user-facing “web server” environment for Metabase
- Metabase is used by the data team
- It is deployed to https://metabase.resn.org.au/
- It runs on Docker on the same ap-southeast-2 VPC as the RDS database
Command Line
- Create a new environment:
eb create --vpc --elb-type application
- Sets load balancer type to application
- Lets you choose VPC (add it to the VPC with the RDS instance)
- Choose default deploy environment:
eb use my-env-name
- Deploy to an environment
eb deploy my-env-name
Configuration Samples
- https://github.com/awsdocs/elastic-beanstalk-samples
- This repo contains examples of configuration files to customise EB applications
Advantages
- Free given our AWS credits (although latest credits are USD$1000 rather than USD$2000)
- Deployed on the most popular cloud host
- No spin-up time (compared to serverless architecture)
Disadvantages
- EB is quite expensive compared to a plain EC2 instance
- Elastic Load Balancing adds ~50% cost on top of the EC2 instances
- Single server, not at edge locations (compared to serverless architecture)
Future
- Node.js backend (WIP) will also be deployed to EB
- In the future, consider serverless/edge options
- Heroku seems like the “Vercel for backends” and should be considered as a more cost-effective alternative to AWS
- Netlify’s Functions are interesting, but would lead to vendor lock-in