SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
Scaling Django Apps using
AWS Elastic Beanstalk
Oct 22nd, 2015
Lushen Wu
Founder, Bebop
http://bebop.com
What we will cover
• What is AWS Elastic Beanstalk (EB)?
• What are the advantages of using EB over
managing EC2 instances / Load-balancing / Auto-
scaling myself?
• What are some common issues I might run into
when deploying my Django app to EB?
Introduction: Bebop’s tech stack
Layer Platform / technology
Client-side jQuery
Devtools
Node.js / Gulp / Sass
Django-compressor
Server (application) Django
Server (language) Python 2.7
Amazon AWS EC2 Amazon S3
• CSS
• Images
• Audio
• Etc.
Amazon RDS
• PostgreSQL
Scaling option 1: manage it yourself
Amazon RDS (database)
Amazon S3 (static assets)
Amazon EC2
(cloud computing)
Amazon EC2
(cloud computing)
Amazon EC2
(cloud computing)
User User User User User User
Instances: either manually
boot up instances or configure
an Auto-scaling policy
Load-balancing: point your
DNS host to the Load
Balancer’s IP address instead
of an EC2 public IP
Use a deployment tool like
Fabric to deploy new
application code to multiple
EC2 instances (e.g. run git pull
on every instance)
+
Load-balancing
Auto-scaling
Core concepts primer
What is AWS auto-scaling?
• AWS monitors your EC2 instances
based on metrics that you specify
(e.g. CPU usage, RAM usage, # of
HTTP requests per minute)
• AWS adds or terminates EC2
instances based on your policy
thresholds (e.g. add instance if
average CPU >60% for 5 minutes,
remove if average CPU < 20% for 5
minutes)
What is AWS load-balancing?
• Distributes incoming requests
among multiple EC2 instances
• Usually routes traffic to instance
with lowest CPU load but you can
specify other policies (e.g. latency)
Scaling option 2: AWS Elastic Beanstalk
Amazon RDS (database)
Amazon S3 (static assets)
Amazon EC2
(cloud computing)
Amazon EC2
(cloud computing)
Amazon EC2
(cloud computing)
User User User User User User
EB web console allows
you to easily configure
Load Balancer and
Autoscaling policy
EB command line tool lets
you easily deploy an
application (in this case,
Django code) to all EC2
instances+
Auto-scaling
Load-balancing
Amazon EB
Quick aside: thoughts on “scaling”
Why is scaling necessary?
• AWS EB/EC2 supports horizontal
scaling (adding more instances) as
well as vertical scaling (using more
powerful instances)
• For speed: You want your web app
to load quickly, and avoid downtime
• For availability: if one datacenter
goes down, people can still access
your web app
Other things to keep in mind:
• Scaling can be expensive, and many site speed
bottlenecks are not solved by adding or upgrading
(e.g. render-blocking javascript/css,
uncompressed or unnecessarily large static
assets, too many HTTP requests)
• Make sure you optimize the basics, e.g.:
minified/gzipped assets, backend caching (e.g.
memcached), frontend caching (e.g. varnish) with
selective AJAX fetching
• We are not using EB to scale the database!
Summary of scaling options
AWS Elastic Beanstalk
• Easier to configure than manually setting up Load Balancer / Autoscaling group
• EB handles source code deployment so you don’t have to use tools like Fabric
Docker
• Briefly looked into it and seemed like EB was sufficient for our needs at the moment
• AWS also supports Docker containers
• Docker just acquired Tutum, potentially easier integrated deployment process
Heroku
• Google search for deploying / scaling Django on Heroku returned some worrying forum posts
Others … ?
EB Overview
1. Creating an EB Environment
2. Configuring an EB Environment
• Instances and scaling
• Environment properties
3. Deployment
4. Recap & tricky snags
1. Creating an EB environment
pip install awsebcli
# check we’re good to go
eb --version
# configure eb with your AWS credentials (Access Key ID, Secret Access Key, default
region, etc.)
eb init
# create an EB environment (will add a .elasticbeanstalk and .ebextensions folder in
your project root)
eb create
Getting started with EB
1. Creating an EB environment
Environment type
• Use ‘Web Server’ environment type
for an external-facing web application
• Make sure the Configuration you use
has a matching PostgreSQL version
with your RDS instance (otherwise
you may run into trouble executing
Postgres commands like ‘pgdump’)
1. You can have more than one environment!
• Testing / Staging -> use smallest EC2 size, 1 or 2 instances in group
• Production -> can be larger EC2 size, at least 3 instances in group
• Workers -> integrate with Amazon SQS, do cronjobs, etc.
2. Instances -> scaling -> deployment
EC2 instance management with Elastic Beanstalk
• Pick the type/size of the EC2 instances that EB will automatically launch
• All instances launched by the auto-scaling policy will be of this type/size!
• You can still manage all EC2 instances as you normally would in the AWS web console for EC2
What size should I pick?
• Remember that you are paying for EC2 instances by the hour, and (AFAIK), even a ping or some background
task using CPU will make that instance count as used
• If you spin up a ton of large instances thinking “Just in case I get a ton of traffic” … you’re gonna get a big bill
How many should I get?
• Having 3 means that you can have one instance down/overwhelmed, one instance deploying new application
version, and still have 1 for failover
2. Instances -> scaling -> deployment
Scaling policy
• Specify minimum and maximum # of instances
• Specify triggers to add or terminate EC2 instances (typically based on CPU usage,
RAM usage, or # of HTTP requests)
• Cooldown: minimum amount of time after a scaling event before another scaling
event can happen… prevents “see-sawing” due to traffic micro spikes
Deployment
• Specify batch size (what # or % of instances to deploy to at the same time)
• Maximum # of instances to deploy to simultaneously
• Minimum # of instances in service
• What could be an issue here?
2. EB Environment Properties
A great way to:
• Avoid committing sensitive
credentials (e.g. social API keys,
DB passwords) into source code
• Deploy same source to different
EB environments (e.g. testing /
staging / production may each
target different databases)
3. Deployment Process
pip install awsebcli
# specify which EB environment to target with subsequent commands
eb use {environment-name}
# output status (e.g. whether currently deploying) and health of target EB environment
eb status
# deploy the latest commit in the current git repository
eb deploy
# dumps logs for whole environment (all instances) into a gzipped file in your project folder
eb logs -z
Using EB command line to deploy
3. What actually happens when you deploy?
What happens in your environment during deployment?
1. ‘eb deploy’ creates a zip file of the latest git commit
• The version you are deploying doesn’t need to be pushed to github, it just
needs to be locally committed
• You can use another revision control platform (e.g. mercurial hg) if you want
2. EB uploads zip file to an S3 bucket associated with your Elastic
Beanstalk account, so it’s accessible by the EB environment
3. EB cycles through your instances and deploys the application to
each ‘deployment batch’ (according to your deployment policy)
3. What actually happens when you deploy?
What happens on an instance during deployment?
• EB runs any server commands you specified (e.g. yum install)
• Extracts source of new version into /opt/python/ondeck
• EB runs any container_commands you specified (e.g. manage.py syncdb)
• If an error is encountered, the deployment aborts, no other instances are
attempted, and the current application version remains active
• If no errors are encountered, EB proceed with deployment:
• Links /opt/python/current/ to the /ondeck/ folder above, WSGI updated
• Django project root is always /opt/python/current/app
3. Helping EB find your Django app
• Options specified in .config
files stored in .ebextensions
folder in project root
• Adds application root to
PYTHONPATH
• Points EB to WSGI
application and configure
threading
option_settings:
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "musicserver.settings"
"PYTHONPATH": "/opt/python/current/app:$PYTHONPATH"
"aws:elasticbeanstalk:container:python":
WSGIPath: musicserver/wsgi.py
NumProcesses: 3
NumThreads: 20
"aws:elasticbeanstalk:container:python:staticfiles":
"/static/": "static/"
Option Settings (Django WSGI config)
3. Customizing server
01_packages.config
Server Commands (this page) and Container Commands (next page)
• Executed in alphabetical order (name them whatever you want)
• You can run arbitrary bash commands, manage linux packages & services, run arbitrary
python code…
More: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
commands:
set_time_zone:
command: ln -f -s /usr/share/zoneinfo/US/Eastern /etc/localtime
02_timezone.config
packages:
yum:
gcc: []
git: []
postgresql93-devel: []
3. Customizing server
Container Commands
• leader_only means only the first
instance in a deployment will run
the command
• Other useful parameters:
ignoreErrors (true|false), env
(name/value pairs), cwd
• This is also the time to set up
dependencies like running chmod
on executables (targeting the
/ondeck/app folder)
03_django.config
container_commands:
01_migrate:
command: "source /opt/python/run/venv/bin/activate &&
python manage.py migrate --noinput"
leader_only: true
02_collectstatic:
command: "source /opt/python/run/venv/bin/activate &&
python manage.py collectstatic --noinput"
leader_only: true
03_compress:
command: "source /opt/python/run/venv/bin/activate &&
python manage.py compress --force"
4. Recap & tricky snags
• Scaling EC2 instances is only one part of the solution!
• Select the right EC2 image version for EB (with same PostgreSQL version as RDS)
• Watch out for devtools-related deployment errors (e.g. collectstatic or compress)
• Get familiar with the deployment flow
• Zip & upload -> run server commands -> extract to /ondeck folder -> run container
commands -> link from /current folder
• Watch out for deployment batch size and minimum instances settings (avoid
“stalled” deployments)
Sources
# SSH invoke Django shell with virtualenv
sudo su
cd /opt/python/current/app
source /opt/python/current/env
source /opt/python/run/venv/bin/activate
python manage.py shell
Bonus snippet:• Google / various blogs
• AWS walkthrough on EB and Django
• About 3 days of head-banging and a
dozen Monster energy drinks in
August 2015
Question time

Weitere ähnliche Inhalte

Was ist angesagt?

Mitchell Hashimoto, HashiCorp
Mitchell Hashimoto, HashiCorpMitchell Hashimoto, HashiCorp
Mitchell Hashimoto, HashiCorpOntico
 
How Ansible Makes Automation Easy
How Ansible Makes Automation EasyHow Ansible Makes Automation Easy
How Ansible Makes Automation EasyPeter Sankauskas
 
Ansible on aws - Pop-up Loft Tel Aviv
Ansible on aws - Pop-up Loft Tel AvivAnsible on aws - Pop-up Loft Tel Aviv
Ansible on aws - Pop-up Loft Tel AvivAmazon Web Services
 
Scaling Django for X Factor - DJUGL Oct 2012
Scaling Django for X Factor - DJUGL Oct 2012Scaling Django for X Factor - DJUGL Oct 2012
Scaling Django for X Factor - DJUGL Oct 2012Malcolm Box
 
Ansible v2 and Beyond (Ansible Hawai'i Meetup)
Ansible v2 and Beyond (Ansible Hawai'i Meetup)Ansible v2 and Beyond (Ansible Hawai'i Meetup)
Ansible v2 and Beyond (Ansible Hawai'i Meetup)Timothy Appnel
 
Plone Hosting: A Panel Discussion
Plone Hosting: A Panel DiscussionPlone Hosting: A Panel Discussion
Plone Hosting: A Panel DiscussionJazkarta, Inc.
 
(WEB307) Scalable Site Management Using AWS OpsWorks | AWS re:Invent 2014
(WEB307) Scalable Site Management Using AWS OpsWorks | AWS re:Invent 2014(WEB307) Scalable Site Management Using AWS OpsWorks | AWS re:Invent 2014
(WEB307) Scalable Site Management Using AWS OpsWorks | AWS re:Invent 2014Amazon Web Services
 
Ansible Intro - June 2015 / Ansible Barcelona User Group
Ansible Intro - June 2015 / Ansible Barcelona User GroupAnsible Intro - June 2015 / Ansible Barcelona User Group
Ansible Intro - June 2015 / Ansible Barcelona User GroupOrestes Carracedo
 
Ansible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeAnsible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeSarah Z
 
AVA - a futuristic test runner
AVA - a futuristic test runnerAVA - a futuristic test runner
AVA - a futuristic test runnerandreaslubbe
 
DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!Jeff Geerling
 
Managing AWS infrastructure using CloudFormation
Managing AWS infrastructure using CloudFormationManaging AWS infrastructure using CloudFormation
Managing AWS infrastructure using CloudFormationAnton Babenko
 
I can't believe it's not a queue: Kafka and Spring
I can't believe it's not a queue: Kafka and SpringI can't believe it's not a queue: Kafka and Spring
I can't believe it's not a queue: Kafka and SpringJoe Kutner
 
Chasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
Chasing AMI - Building Amazon machine images with Puppet, Packer and JenkinsChasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
Chasing AMI - Building Amazon machine images with Puppet, Packer and JenkinsTomas Doran
 
Drupal VM for Drupal 8 Dev - MidCamp 2017
Drupal VM for Drupal 8 Dev - MidCamp 2017Drupal VM for Drupal 8 Dev - MidCamp 2017
Drupal VM for Drupal 8 Dev - MidCamp 2017Jeff Geerling
 
Configuration primer
Configuration primerConfiguration primer
Configuration primerfeanil
 

Was ist angesagt? (20)

Mitchell Hashimoto, HashiCorp
Mitchell Hashimoto, HashiCorpMitchell Hashimoto, HashiCorp
Mitchell Hashimoto, HashiCorp
 
How Ansible Makes Automation Easy
How Ansible Makes Automation EasyHow Ansible Makes Automation Easy
How Ansible Makes Automation Easy
 
Ansible on aws - Pop-up Loft Tel Aviv
Ansible on aws - Pop-up Loft Tel AvivAnsible on aws - Pop-up Loft Tel Aviv
Ansible on aws - Pop-up Loft Tel Aviv
 
Scaling Django for X Factor - DJUGL Oct 2012
Scaling Django for X Factor - DJUGL Oct 2012Scaling Django for X Factor - DJUGL Oct 2012
Scaling Django for X Factor - DJUGL Oct 2012
 
JRubyConf 2009
JRubyConf 2009JRubyConf 2009
JRubyConf 2009
 
Ansible v2 and Beyond (Ansible Hawai'i Meetup)
Ansible v2 and Beyond (Ansible Hawai'i Meetup)Ansible v2 and Beyond (Ansible Hawai'i Meetup)
Ansible v2 and Beyond (Ansible Hawai'i Meetup)
 
Plone Hosting: A Panel Discussion
Plone Hosting: A Panel DiscussionPlone Hosting: A Panel Discussion
Plone Hosting: A Panel Discussion
 
(WEB307) Scalable Site Management Using AWS OpsWorks | AWS re:Invent 2014
(WEB307) Scalable Site Management Using AWS OpsWorks | AWS re:Invent 2014(WEB307) Scalable Site Management Using AWS OpsWorks | AWS re:Invent 2014
(WEB307) Scalable Site Management Using AWS OpsWorks | AWS re:Invent 2014
 
Ansible Intro - June 2015 / Ansible Barcelona User Group
Ansible Intro - June 2015 / Ansible Barcelona User GroupAnsible Intro - June 2015 / Ansible Barcelona User Group
Ansible Intro - June 2015 / Ansible Barcelona User Group
 
Corley scalability
Corley scalabilityCorley scalability
Corley scalability
 
Ansible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeAnsible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less Coffee
 
AVA - a futuristic test runner
AVA - a futuristic test runnerAVA - a futuristic test runner
AVA - a futuristic test runner
 
DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!
 
Managing AWS infrastructure using CloudFormation
Managing AWS infrastructure using CloudFormationManaging AWS infrastructure using CloudFormation
Managing AWS infrastructure using CloudFormation
 
I can't believe it's not a queue: Kafka and Spring
I can't believe it's not a queue: Kafka and SpringI can't believe it's not a queue: Kafka and Spring
I can't believe it's not a queue: Kafka and Spring
 
Chasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
Chasing AMI - Building Amazon machine images with Puppet, Packer and JenkinsChasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
Chasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
 
Drupal VM for Drupal 8 Dev - MidCamp 2017
Drupal VM for Drupal 8 Dev - MidCamp 2017Drupal VM for Drupal 8 Dev - MidCamp 2017
Drupal VM for Drupal 8 Dev - MidCamp 2017
 
Ansible Case Studies
Ansible Case StudiesAnsible Case Studies
Ansible Case Studies
 
Dev-Friendly Ops
Dev-Friendly OpsDev-Friendly Ops
Dev-Friendly Ops
 
Configuration primer
Configuration primerConfiguration primer
Configuration primer
 

Andere mochten auch

Reviews.co.uk - Power Of Reviews
Reviews.co.uk - Power Of ReviewsReviews.co.uk - Power Of Reviews
Reviews.co.uk - Power Of ReviewsCallum McKeefery
 
AWS: Scaling With Elastic Beanstalk
AWS: Scaling With Elastic BeanstalkAWS: Scaling With Elastic Beanstalk
AWS: Scaling With Elastic BeanstalkKMS Technology
 
An Engineers Guide to the AWS Ruby SDK
An Engineers Guide to the AWS Ruby SDKAn Engineers Guide to the AWS Ruby SDK
An Engineers Guide to the AWS Ruby SDK😸 Richard Spindler
 
AWS EC2 Container Service (ECS) In Action - iMasters Developer Week - Vitoria
AWS EC2 Container Service (ECS) In Action - iMasters Developer Week - VitoriaAWS EC2 Container Service (ECS) In Action - iMasters Developer Week - Vitoria
AWS EC2 Container Service (ECS) In Action - iMasters Developer Week - VitoriaHeitor Vital
 
AWS Elastic Beanstalk and Docker
AWS Elastic Beanstalk and DockerAWS Elastic Beanstalk and Docker
AWS Elastic Beanstalk and DockerEvan Brown
 
Docker on AWS - the Right Way
Docker on AWS - the Right WayDocker on AWS - the Right Way
Docker on AWS - the Right WayAllCloud
 
Apache Spark Clusters for Everyone | AWS Public Sector Summit 2016
Apache Spark Clusters for Everyone | AWS Public Sector Summit 2016Apache Spark Clusters for Everyone | AWS Public Sector Summit 2016
Apache Spark Clusters for Everyone | AWS Public Sector Summit 2016Amazon Web Services
 
Deployment and Management on AWS:
 A Deep Dive on Options and Tools
Deployment and Management on AWS:
 A Deep Dive on Options and ToolsDeployment and Management on AWS:
 A Deep Dive on Options and Tools
Deployment and Management on AWS:
 A Deep Dive on Options and ToolsDanilo Poccia
 
(APP313) NEW LAUNCH: Amazon EC2 Container Service in Action | AWS re:Invent 2014
(APP313) NEW LAUNCH: Amazon EC2 Container Service in Action | AWS re:Invent 2014(APP313) NEW LAUNCH: Amazon EC2 Container Service in Action | AWS re:Invent 2014
(APP313) NEW LAUNCH: Amazon EC2 Container Service in Action | AWS re:Invent 2014Amazon Web Services
 
Apache Kafka, and the Rise of Stream Processing
Apache Kafka, and the Rise of Stream ProcessingApache Kafka, and the Rise of Stream Processing
Apache Kafka, and the Rise of Stream ProcessingGuozhang Wang
 
TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...
TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...
TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...Amazon Web Services
 
Demystifying Stream Processing with Apache Kafka
Demystifying Stream Processing with Apache KafkaDemystifying Stream Processing with Apache Kafka
Demystifying Stream Processing with Apache Kafkaconfluent
 
Scalable Django Architecture
Scalable Django ArchitectureScalable Django Architecture
Scalable Django ArchitectureRami Sayar
 
Data Pipelines with Kafka Connect
Data Pipelines with Kafka ConnectData Pipelines with Kafka Connect
Data Pipelines with Kafka ConnectKaufman Ng
 
AWS re:Invent 2016: Workshop: Deploy a Swift Web Application on Amazon ECS (C...
AWS re:Invent 2016: Workshop: Deploy a Swift Web Application on Amazon ECS (C...AWS re:Invent 2016: Workshop: Deploy a Swift Web Application on Amazon ECS (C...
AWS re:Invent 2016: Workshop: Deploy a Swift Web Application on Amazon ECS (C...Amazon Web Services
 
Introduction to Apache Kafka- Part 1
Introduction to Apache Kafka- Part 1Introduction to Apache Kafka- Part 1
Introduction to Apache Kafka- Part 1Knoldus Inc.
 
5 Reasons Why You Should Consider Migrating Web Apps to the Cloud on AWS
5 Reasons Why You Should Consider Migrating Web Apps to the Cloud on AWS5 Reasons Why You Should Consider Migrating Web Apps to the Cloud on AWS
5 Reasons Why You Should Consider Migrating Web Apps to the Cloud on AWSrivetlogic
 
Introducing Apache Kafka's Streams API - Kafka meetup Munich, Jan 25 2017
Introducing Apache Kafka's Streams API - Kafka meetup Munich, Jan 25 2017Introducing Apache Kafka's Streams API - Kafka meetup Munich, Jan 25 2017
Introducing Apache Kafka's Streams API - Kafka meetup Munich, Jan 25 2017Michael Noll
 

Andere mochten auch (20)

Django Deployment-in-AWS
Django Deployment-in-AWSDjango Deployment-in-AWS
Django Deployment-in-AWS
 
Reviews.co.uk - Power Of Reviews
Reviews.co.uk - Power Of ReviewsReviews.co.uk - Power Of Reviews
Reviews.co.uk - Power Of Reviews
 
AWS: Scaling With Elastic Beanstalk
AWS: Scaling With Elastic BeanstalkAWS: Scaling With Elastic Beanstalk
AWS: Scaling With Elastic Beanstalk
 
An Engineers Guide to the AWS Ruby SDK
An Engineers Guide to the AWS Ruby SDKAn Engineers Guide to the AWS Ruby SDK
An Engineers Guide to the AWS Ruby SDK
 
AWS EC2 Container Service (ECS) In Action - iMasters Developer Week - Vitoria
AWS EC2 Container Service (ECS) In Action - iMasters Developer Week - VitoriaAWS EC2 Container Service (ECS) In Action - iMasters Developer Week - Vitoria
AWS EC2 Container Service (ECS) In Action - iMasters Developer Week - Vitoria
 
AWS Elastic Beanstalk and Docker
AWS Elastic Beanstalk and DockerAWS Elastic Beanstalk and Docker
AWS Elastic Beanstalk and Docker
 
Docker on AWS - the Right Way
Docker on AWS - the Right WayDocker on AWS - the Right Way
Docker on AWS - the Right Way
 
Docker on AWS
Docker on AWSDocker on AWS
Docker on AWS
 
Apache Spark Clusters for Everyone | AWS Public Sector Summit 2016
Apache Spark Clusters for Everyone | AWS Public Sector Summit 2016Apache Spark Clusters for Everyone | AWS Public Sector Summit 2016
Apache Spark Clusters for Everyone | AWS Public Sector Summit 2016
 
Deployment and Management on AWS:
 A Deep Dive on Options and Tools
Deployment and Management on AWS:
 A Deep Dive on Options and ToolsDeployment and Management on AWS:
 A Deep Dive on Options and Tools
Deployment and Management on AWS:
 A Deep Dive on Options and Tools
 
(APP313) NEW LAUNCH: Amazon EC2 Container Service in Action | AWS re:Invent 2014
(APP313) NEW LAUNCH: Amazon EC2 Container Service in Action | AWS re:Invent 2014(APP313) NEW LAUNCH: Amazon EC2 Container Service in Action | AWS re:Invent 2014
(APP313) NEW LAUNCH: Amazon EC2 Container Service in Action | AWS re:Invent 2014
 
Apache Kafka, and the Rise of Stream Processing
Apache Kafka, and the Rise of Stream ProcessingApache Kafka, and the Rise of Stream Processing
Apache Kafka, and the Rise of Stream Processing
 
TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...
TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...
TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...
 
Demystifying Stream Processing with Apache Kafka
Demystifying Stream Processing with Apache KafkaDemystifying Stream Processing with Apache Kafka
Demystifying Stream Processing with Apache Kafka
 
Scalable Django Architecture
Scalable Django ArchitectureScalable Django Architecture
Scalable Django Architecture
 
Data Pipelines with Kafka Connect
Data Pipelines with Kafka ConnectData Pipelines with Kafka Connect
Data Pipelines with Kafka Connect
 
AWS re:Invent 2016: Workshop: Deploy a Swift Web Application on Amazon ECS (C...
AWS re:Invent 2016: Workshop: Deploy a Swift Web Application on Amazon ECS (C...AWS re:Invent 2016: Workshop: Deploy a Swift Web Application on Amazon ECS (C...
AWS re:Invent 2016: Workshop: Deploy a Swift Web Application on Amazon ECS (C...
 
Introduction to Apache Kafka- Part 1
Introduction to Apache Kafka- Part 1Introduction to Apache Kafka- Part 1
Introduction to Apache Kafka- Part 1
 
5 Reasons Why You Should Consider Migrating Web Apps to the Cloud on AWS
5 Reasons Why You Should Consider Migrating Web Apps to the Cloud on AWS5 Reasons Why You Should Consider Migrating Web Apps to the Cloud on AWS
5 Reasons Why You Should Consider Migrating Web Apps to the Cloud on AWS
 
Introducing Apache Kafka's Streams API - Kafka meetup Munich, Jan 25 2017
Introducing Apache Kafka's Streams API - Kafka meetup Munich, Jan 25 2017Introducing Apache Kafka's Streams API - Kafka meetup Munich, Jan 25 2017
Introducing Apache Kafka's Streams API - Kafka meetup Munich, Jan 25 2017
 

Ähnlich wie Scaling Django Apps using AWS Elastic Beanstalk

AWS Elastic Beanstalk: Running Multi-Container Docker Applications - DevDay L...
AWS Elastic Beanstalk: Running Multi-Container Docker Applications - DevDay L...AWS Elastic Beanstalk: Running Multi-Container Docker Applications - DevDay L...
AWS Elastic Beanstalk: Running Multi-Container Docker Applications - DevDay L...Amazon Web Services
 
DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014scolestock
 
Managing Docker & ECS Based Applications with AWS Elastic Beanstalk - DevDay ...
Managing Docker & ECS Based Applications with AWS Elastic Beanstalk - DevDay ...Managing Docker & ECS Based Applications with AWS Elastic Beanstalk - DevDay ...
Managing Docker & ECS Based Applications with AWS Elastic Beanstalk - DevDay ...Amazon Web Services
 
Distribua, gerencie e escale suas aplicações com o aws elastic beanstalk
Distribua, gerencie e escale suas aplicações com o aws elastic beanstalkDistribua, gerencie e escale suas aplicações com o aws elastic beanstalk
Distribua, gerencie e escale suas aplicações com o aws elastic beanstalkAmazon Web Services LATAM
 
AWS (Hadoop) Meetup 30.04.09
AWS (Hadoop) Meetup 30.04.09AWS (Hadoop) Meetup 30.04.09
AWS (Hadoop) Meetup 30.04.09Chris Purrington
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeededm00se
 
AWS July Webinar Series-Deploying and Scaling Web Application with AWS Elasti...
AWS July Webinar Series-Deploying and Scaling Web Application with AWS Elasti...AWS July Webinar Series-Deploying and Scaling Web Application with AWS Elasti...
AWS July Webinar Series-Deploying and Scaling Web Application with AWS Elasti...Amazon Web Services
 
Azure Templates for Consistent Deployment
Azure Templates for Consistent DeploymentAzure Templates for Consistent Deployment
Azure Templates for Consistent DeploymentJosé Maia
 
Advanced Container Management and Scheduling
Advanced Container Management and SchedulingAdvanced Container Management and Scheduling
Advanced Container Management and SchedulingAmazon Web Services
 
Deploy, Scale and Manage your Application with AWS Elastic Beanstalk
Deploy, Scale and Manage your Application with AWS Elastic BeanstalkDeploy, Scale and Manage your Application with AWS Elastic Beanstalk
Deploy, Scale and Manage your Application with AWS Elastic BeanstalkAmazon Web Services
 
ECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container Day
ECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container DayECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container Day
ECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container DayAmazon Web Services Korea
 
UKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUlrich Krause
 
XPages -Beyond the Basics
XPages -Beyond the BasicsXPages -Beyond the Basics
XPages -Beyond the BasicsUlrich Krause
 
Aws-What You Need to Know_Simon Elisha
Aws-What You Need to Know_Simon ElishaAws-What You Need to Know_Simon Elisha
Aws-What You Need to Know_Simon ElishaHelen Rogers
 
[DanNotes] XPages - Beyound the Basics
[DanNotes] XPages - Beyound the Basics[DanNotes] XPages - Beyound the Basics
[DanNotes] XPages - Beyound the BasicsUlrich Krause
 
Deploy, Scale and Manage your Application with AWS Elastic Beanstalk
Deploy, Scale and Manage your Application with AWS Elastic BeanstalkDeploy, Scale and Manage your Application with AWS Elastic Beanstalk
Deploy, Scale and Manage your Application with AWS Elastic BeanstalkAmazon Web Services
 
Migrating enterprise workloads to AWS
Migrating enterprise workloads to AWSMigrating enterprise workloads to AWS
Migrating enterprise workloads to AWSTom Laszewski
 

Ähnlich wie Scaling Django Apps using AWS Elastic Beanstalk (20)

AWS Elastic Beanstalk: Running Multi-Container Docker Applications - DevDay L...
AWS Elastic Beanstalk: Running Multi-Container Docker Applications - DevDay L...AWS Elastic Beanstalk: Running Multi-Container Docker Applications - DevDay L...
AWS Elastic Beanstalk: Running Multi-Container Docker Applications - DevDay L...
 
DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014
 
Managing Docker & ECS Based Applications with AWS Elastic Beanstalk - DevDay ...
Managing Docker & ECS Based Applications with AWS Elastic Beanstalk - DevDay ...Managing Docker & ECS Based Applications with AWS Elastic Beanstalk - DevDay ...
Managing Docker & ECS Based Applications with AWS Elastic Beanstalk - DevDay ...
 
Advanced Container Scheduling
Advanced Container SchedulingAdvanced Container Scheduling
Advanced Container Scheduling
 
Distribua, gerencie e escale suas aplicações com o aws elastic beanstalk
Distribua, gerencie e escale suas aplicações com o aws elastic beanstalkDistribua, gerencie e escale suas aplicações com o aws elastic beanstalk
Distribua, gerencie e escale suas aplicações com o aws elastic beanstalk
 
AWS (Hadoop) Meetup 30.04.09
AWS (Hadoop) Meetup 30.04.09AWS (Hadoop) Meetup 30.04.09
AWS (Hadoop) Meetup 30.04.09
 
Deep Dive into AWS Fargate
Deep Dive into AWS FargateDeep Dive into AWS Fargate
Deep Dive into AWS Fargate
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
 
AWS July Webinar Series-Deploying and Scaling Web Application with AWS Elasti...
AWS July Webinar Series-Deploying and Scaling Web Application with AWS Elasti...AWS July Webinar Series-Deploying and Scaling Web Application with AWS Elasti...
AWS July Webinar Series-Deploying and Scaling Web Application with AWS Elasti...
 
Azure Templates for Consistent Deployment
Azure Templates for Consistent DeploymentAzure Templates for Consistent Deployment
Azure Templates for Consistent Deployment
 
Advanced Container Management and Scheduling
Advanced Container Management and SchedulingAdvanced Container Management and Scheduling
Advanced Container Management and Scheduling
 
Deploy, Scale and Manage your Application with AWS Elastic Beanstalk
Deploy, Scale and Manage your Application with AWS Elastic BeanstalkDeploy, Scale and Manage your Application with AWS Elastic Beanstalk
Deploy, Scale and Manage your Application with AWS Elastic Beanstalk
 
ECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container Day
ECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container DayECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container Day
ECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container Day
 
UKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basics
 
XPages -Beyond the Basics
XPages -Beyond the BasicsXPages -Beyond the Basics
XPages -Beyond the Basics
 
Aws-What You Need to Know_Simon Elisha
Aws-What You Need to Know_Simon ElishaAws-What You Need to Know_Simon Elisha
Aws-What You Need to Know_Simon Elisha
 
[DanNotes] XPages - Beyound the Basics
[DanNotes] XPages - Beyound the Basics[DanNotes] XPages - Beyound the Basics
[DanNotes] XPages - Beyound the Basics
 
Deploy, Scale and Manage your Application with AWS Elastic Beanstalk
Deploy, Scale and Manage your Application with AWS Elastic BeanstalkDeploy, Scale and Manage your Application with AWS Elastic Beanstalk
Deploy, Scale and Manage your Application with AWS Elastic Beanstalk
 
Migrating enterprise workloads to AWS
Migrating enterprise workloads to AWSMigrating enterprise workloads to AWS
Migrating enterprise workloads to AWS
 
Meanstack overview
Meanstack overviewMeanstack overview
Meanstack overview
 

Kürzlich hochgeladen

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 

Kürzlich hochgeladen (20)

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 

Scaling Django Apps using AWS Elastic Beanstalk

  • 1. Scaling Django Apps using AWS Elastic Beanstalk Oct 22nd, 2015 Lushen Wu Founder, Bebop http://bebop.com
  • 2. What we will cover • What is AWS Elastic Beanstalk (EB)? • What are the advantages of using EB over managing EC2 instances / Load-balancing / Auto- scaling myself? • What are some common issues I might run into when deploying my Django app to EB?
  • 3. Introduction: Bebop’s tech stack Layer Platform / technology Client-side jQuery Devtools Node.js / Gulp / Sass Django-compressor Server (application) Django Server (language) Python 2.7 Amazon AWS EC2 Amazon S3 • CSS • Images • Audio • Etc. Amazon RDS • PostgreSQL
  • 4. Scaling option 1: manage it yourself Amazon RDS (database) Amazon S3 (static assets) Amazon EC2 (cloud computing) Amazon EC2 (cloud computing) Amazon EC2 (cloud computing) User User User User User User Instances: either manually boot up instances or configure an Auto-scaling policy Load-balancing: point your DNS host to the Load Balancer’s IP address instead of an EC2 public IP Use a deployment tool like Fabric to deploy new application code to multiple EC2 instances (e.g. run git pull on every instance) + Load-balancing Auto-scaling
  • 5. Core concepts primer What is AWS auto-scaling? • AWS monitors your EC2 instances based on metrics that you specify (e.g. CPU usage, RAM usage, # of HTTP requests per minute) • AWS adds or terminates EC2 instances based on your policy thresholds (e.g. add instance if average CPU >60% for 5 minutes, remove if average CPU < 20% for 5 minutes) What is AWS load-balancing? • Distributes incoming requests among multiple EC2 instances • Usually routes traffic to instance with lowest CPU load but you can specify other policies (e.g. latency)
  • 6. Scaling option 2: AWS Elastic Beanstalk Amazon RDS (database) Amazon S3 (static assets) Amazon EC2 (cloud computing) Amazon EC2 (cloud computing) Amazon EC2 (cloud computing) User User User User User User EB web console allows you to easily configure Load Balancer and Autoscaling policy EB command line tool lets you easily deploy an application (in this case, Django code) to all EC2 instances+ Auto-scaling Load-balancing Amazon EB
  • 7. Quick aside: thoughts on “scaling” Why is scaling necessary? • AWS EB/EC2 supports horizontal scaling (adding more instances) as well as vertical scaling (using more powerful instances) • For speed: You want your web app to load quickly, and avoid downtime • For availability: if one datacenter goes down, people can still access your web app Other things to keep in mind: • Scaling can be expensive, and many site speed bottlenecks are not solved by adding or upgrading (e.g. render-blocking javascript/css, uncompressed or unnecessarily large static assets, too many HTTP requests) • Make sure you optimize the basics, e.g.: minified/gzipped assets, backend caching (e.g. memcached), frontend caching (e.g. varnish) with selective AJAX fetching • We are not using EB to scale the database!
  • 8. Summary of scaling options AWS Elastic Beanstalk • Easier to configure than manually setting up Load Balancer / Autoscaling group • EB handles source code deployment so you don’t have to use tools like Fabric Docker • Briefly looked into it and seemed like EB was sufficient for our needs at the moment • AWS also supports Docker containers • Docker just acquired Tutum, potentially easier integrated deployment process Heroku • Google search for deploying / scaling Django on Heroku returned some worrying forum posts Others … ?
  • 9. EB Overview 1. Creating an EB Environment 2. Configuring an EB Environment • Instances and scaling • Environment properties 3. Deployment 4. Recap & tricky snags
  • 10. 1. Creating an EB environment pip install awsebcli # check we’re good to go eb --version # configure eb with your AWS credentials (Access Key ID, Secret Access Key, default region, etc.) eb init # create an EB environment (will add a .elasticbeanstalk and .ebextensions folder in your project root) eb create Getting started with EB
  • 11. 1. Creating an EB environment Environment type • Use ‘Web Server’ environment type for an external-facing web application • Make sure the Configuration you use has a matching PostgreSQL version with your RDS instance (otherwise you may run into trouble executing Postgres commands like ‘pgdump’)
  • 12. 1. You can have more than one environment! • Testing / Staging -> use smallest EC2 size, 1 or 2 instances in group • Production -> can be larger EC2 size, at least 3 instances in group • Workers -> integrate with Amazon SQS, do cronjobs, etc.
  • 13. 2. Instances -> scaling -> deployment EC2 instance management with Elastic Beanstalk • Pick the type/size of the EC2 instances that EB will automatically launch • All instances launched by the auto-scaling policy will be of this type/size! • You can still manage all EC2 instances as you normally would in the AWS web console for EC2 What size should I pick? • Remember that you are paying for EC2 instances by the hour, and (AFAIK), even a ping or some background task using CPU will make that instance count as used • If you spin up a ton of large instances thinking “Just in case I get a ton of traffic” … you’re gonna get a big bill How many should I get? • Having 3 means that you can have one instance down/overwhelmed, one instance deploying new application version, and still have 1 for failover
  • 14. 2. Instances -> scaling -> deployment Scaling policy • Specify minimum and maximum # of instances • Specify triggers to add or terminate EC2 instances (typically based on CPU usage, RAM usage, or # of HTTP requests) • Cooldown: minimum amount of time after a scaling event before another scaling event can happen… prevents “see-sawing” due to traffic micro spikes Deployment • Specify batch size (what # or % of instances to deploy to at the same time) • Maximum # of instances to deploy to simultaneously • Minimum # of instances in service • What could be an issue here?
  • 15. 2. EB Environment Properties A great way to: • Avoid committing sensitive credentials (e.g. social API keys, DB passwords) into source code • Deploy same source to different EB environments (e.g. testing / staging / production may each target different databases)
  • 16. 3. Deployment Process pip install awsebcli # specify which EB environment to target with subsequent commands eb use {environment-name} # output status (e.g. whether currently deploying) and health of target EB environment eb status # deploy the latest commit in the current git repository eb deploy # dumps logs for whole environment (all instances) into a gzipped file in your project folder eb logs -z Using EB command line to deploy
  • 17. 3. What actually happens when you deploy? What happens in your environment during deployment? 1. ‘eb deploy’ creates a zip file of the latest git commit • The version you are deploying doesn’t need to be pushed to github, it just needs to be locally committed • You can use another revision control platform (e.g. mercurial hg) if you want 2. EB uploads zip file to an S3 bucket associated with your Elastic Beanstalk account, so it’s accessible by the EB environment 3. EB cycles through your instances and deploys the application to each ‘deployment batch’ (according to your deployment policy)
  • 18. 3. What actually happens when you deploy? What happens on an instance during deployment? • EB runs any server commands you specified (e.g. yum install) • Extracts source of new version into /opt/python/ondeck • EB runs any container_commands you specified (e.g. manage.py syncdb) • If an error is encountered, the deployment aborts, no other instances are attempted, and the current application version remains active • If no errors are encountered, EB proceed with deployment: • Links /opt/python/current/ to the /ondeck/ folder above, WSGI updated • Django project root is always /opt/python/current/app
  • 19. 3. Helping EB find your Django app • Options specified in .config files stored in .ebextensions folder in project root • Adds application root to PYTHONPATH • Points EB to WSGI application and configure threading option_settings: "aws:elasticbeanstalk:application:environment": DJANGO_SETTINGS_MODULE: "musicserver.settings" "PYTHONPATH": "/opt/python/current/app:$PYTHONPATH" "aws:elasticbeanstalk:container:python": WSGIPath: musicserver/wsgi.py NumProcesses: 3 NumThreads: 20 "aws:elasticbeanstalk:container:python:staticfiles": "/static/": "static/" Option Settings (Django WSGI config)
  • 20. 3. Customizing server 01_packages.config Server Commands (this page) and Container Commands (next page) • Executed in alphabetical order (name them whatever you want) • You can run arbitrary bash commands, manage linux packages & services, run arbitrary python code… More: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html commands: set_time_zone: command: ln -f -s /usr/share/zoneinfo/US/Eastern /etc/localtime 02_timezone.config packages: yum: gcc: [] git: [] postgresql93-devel: []
  • 21. 3. Customizing server Container Commands • leader_only means only the first instance in a deployment will run the command • Other useful parameters: ignoreErrors (true|false), env (name/value pairs), cwd • This is also the time to set up dependencies like running chmod on executables (targeting the /ondeck/app folder) 03_django.config container_commands: 01_migrate: command: "source /opt/python/run/venv/bin/activate && python manage.py migrate --noinput" leader_only: true 02_collectstatic: command: "source /opt/python/run/venv/bin/activate && python manage.py collectstatic --noinput" leader_only: true 03_compress: command: "source /opt/python/run/venv/bin/activate && python manage.py compress --force"
  • 22. 4. Recap & tricky snags • Scaling EC2 instances is only one part of the solution! • Select the right EC2 image version for EB (with same PostgreSQL version as RDS) • Watch out for devtools-related deployment errors (e.g. collectstatic or compress) • Get familiar with the deployment flow • Zip & upload -> run server commands -> extract to /ondeck folder -> run container commands -> link from /current folder • Watch out for deployment batch size and minimum instances settings (avoid “stalled” deployments)
  • 23. Sources # SSH invoke Django shell with virtualenv sudo su cd /opt/python/current/app source /opt/python/current/env source /opt/python/run/venv/bin/activate python manage.py shell Bonus snippet:• Google / various blogs • AWS walkthrough on EB and Django • About 3 days of head-banging and a dozen Monster energy drinks in August 2015