BEANSTALK Flashcards
Beanstalk overview
EC2, ASG, ELB, RDS etc
Uses all these, can see as one view in the UI
Can have full control of configurations
Beanstalk is FREE
-Managed Service
Instance Config/OS handled by beanstalk
Deployment strategy is configurable but managed by beanstalk
Just application code is developer responsibility
THREE Architecture model Single Instance deploy: development ELB+ASG Good for production/ preproduction WEB APPLICATION ASG only: Good for workers NONWEB APPS
Beanstalk supports: Single Container docker Multicontainer docker Preconfig docker java , php, python etc.
Beanstalk overview COMPONENTS
Application
Application version
Environment name
- Application- CODE
- Application version - Each deployment of code gets version
- Environment name - what name of deployment, TEST PROD ETC
Beanstalk can deploy but also rollback to previous APPLICATION VERSION.
ex:
Code is deployed onto environment name test, this deployment is version 1.
Beanstalk DEPLOYMENT MODES
Single Instance
vs
High Availability
Single instance:
ALL WITHIN ONE AZ::
DNS name maps to ELASTIC IP ADDRESS
Development
One EC2 instance
One ELP
One ASG
DB optional
=============================================
High Availability with Load Balancer: Production
ON TOP
ELB on top: DNS name routes to ELB DNS name
ELB maps to multiple AZ:
ASG spans multiple AZ also:
In Each AZ you have a EC2 instance inside a security group that is the WEB app server
These EC2 instances may talk to RDS on multiple AZ, may have master and standby on separate AZ, not all AZ need a RDS.
Beanstalk DEPLOYMENT MODES UPDATING : ALL at once speed downtime good for? cost?
(single environment)
Turn all of, then convert all to V2
FASTEST
Application has downtime
Good for quick interation versions in development
NO ADDITIONAL COST
Beanstalk DEPLOYMENT MODES UPDATING : ROLLING Speed downtime good for cost? capacity
(single environment)
Half capacity, instances will turn off half at a time, convert to v2 then start process with other side
fast LONG DEPLOYMENT
Runs below capacity based on bucket size
Can set BUCKET SIZE: number of Ec2 instances that are affected
Application is running BOTH versions simultaneously
NO ADDITIONAL COST
Beanstalk DEPLOYMENT MODES UPDATING : ROLLING WITH ADDITIONAL BATCHES Speed downtime good for cost? capacity
(single environment) Run at capacity Set a specific bucket size Run both versions HAS SMALL ADDITIONAL COST, additional buckets removed later GOOD FOR PRODUCTION
Longer deployment
Add additional instances based on bucket size, after additional are running v2, then original buckets start processing based on bucket size.
Beanstalk DEPLOYMENT MODES UPDATING : IMMUTABLE Speed downtime good for cost? capacity
(single environment)
INSTANCES FROM NEW TEMP ASG
New auto scaling group costs more
Most cost Fastest Rollback for contingency Great choice for prod for additional cost full capacity plus more no downtime
Replicate to new ASG
- Launch one, validate that this version works
- If working then launches rest
Merge ASG, Temporary ASG will start moving instances into NEW ASG. If failure, then need to terminate temporary ASG
Beanstalk DEPLOYMENT MODES
BLUE GREEN
(MULTIPLE ENVIROMENT)
Zero downtime
for testing
Deploy a new stage environment with its own version
ZERO downtime.
Use Route 52 to start routing traffic percentages from old to new over time
Canary, weighted etc
When ready, SWAP URL to make it PROD. This is a method, but not embedded into beanstalk. MANUAL OPERATION.
Elastic Beanstalk CLI “EB CLI”
Allows automation of development pipeline
EB CLI, working with EB from cli is much easier.
Commands like EB create status health events logs open deploy config
Elastic Beanstalk Deployment process
- Describe Dependencies
Requirements.txt python
package.json Node.js - A. CONSOLE: upload file into beanstalk, a new app version will be created, Now can be deployed.
- B. CLI: Create new app version using CLI (uploads ZIP) then deploy
ZIP when uploaded to Beanstalk gets uploaded to S3, Beanstalk refers to S3 bundle
Beanstalk will deploy zip on each Ec2, resolve dependencies and START application.
Elastic Beanstalk Extensions
Zip file containing code must be deployed to Beanstalk, this zip file can contain parameters that are normally set in UI to be configured in code using EBEXTENSIONS
configuration files must be Located in .ebextensions/ directory of ROOT SOURCE CODE
YAML / JSON format, (name must end with .config—>example.config)
*CAN MODIFY DEFAULT OPTIONS: modify settings in Option_settings file
EBextensions can add resources such as RDS , elasticache, DynamoDB etc.
ALL RESOURCES MADE IN THIS MANNER WILL BE DELETED IF BEANSTALK DEPLOYMENT IS DELETED.
Beanstalk and Cloudformation
Beanstalk relies on Cloudformation, it uses it as a basis for operations.
using Cloudformation resources in .EBEXTENSIONS, will allow you to provision anything you like , like cloudformation normally would do
Beanstalk Cloning
Clone existing into new with exact same config
GOOD TO DEPLOY A TEST VERSION OF AN APP
All resources and config are preserved.
Load balancer and config
RDS database type (not the RDS data though)
environment variables
Beanstalk and Migration: Load balancer
after creating elastic beanstalk environment you cannot change the ELASTIC LOAD BALANCER TYPE
after creating elastic beanstalk environment you cannot change the ELASTIC LOAD BALANCER TYPE
- Create a new environment with a cloned config, change the ELB
- Deploy application onto NEW environment
- CNAME swap or Route 53 update to shift traffic
Beanstalk and Migration: RDS
RDS that is launched with Beanstalk will be taken offline if Beanstalk goes offline:
Need to Decouple: Separate RDS database and provide EB with connection string.
How to do this through an EB created RDS
- Create snapshot of RDS database
- Go to RDS console and PROTECT DATABASE FROM DELETION*
- Create a new EB environment without RDS, use environment variable to connect to old RDS
- Cname swap/ route 53 change and confirm if its working
Terminate Old environment, RDS will not be terminated due to RDS protection, You will need to delete the cloud formation stack manually because termination will fail.