SlideShare a Scribd company logo
Safely
         Deploying on
         the cutting edge
         Eric Holscher
         Urban Airship
         Djangocon 2011



Wednesday, September 7, 2011
Wednesday, September 7, 2011
Talk Contents



         •   Company culture & process
         •   Deployment environment
         •   Tools for deploying
         •   Verifying deployment




Wednesday, September 7, 2011
Process




Wednesday, September 7, 2011
Process

         •   Deploy out of git
         •   Standard git-based production/master branch model
         •   Production branch has releases are tagged with timestamp
             •   deploy-2011-08-03_14-37-38
         •   Feature branches
         •   http://nvie.com/posts/a-successful-git-branching-model/




Wednesday, September 7, 2011
Features



         •   Easily allows you to hot-fix production
         •   Keep a stable master
         •   Run CI on the master branch or long-lived feature branches




Wednesday, September 7, 2011
Services

         •   Everything that we deploy is conceptualized as a service
         •   Services all live in /mnt/services/<slug> (Thanks ec2)
         •   A service is an instance of a repository on a machine
         •   A repository might have multiple services
             •   eg. Airship deployed into “celery” and “web” services
         •   This maps really well onto Chef cookbooks




Wednesday, September 7, 2011
QA Environment


         •   Run all of your master branches
         •   Allow you to get a copy of what will become production
         •   Catch errors before they are seen by customers
         •   Spawn new ones for long-lived feature branches
         •   `host web-0` and figure out based on IP




Wednesday, September 7, 2011
Deployment Design Goals




Wednesday, September 7, 2011
Jump machine




         •   Have a standard place for all deployments to happen
         •   Log all commands run




Wednesday, September 7, 2011
No External Services



         •   Chishop
         •   No external server required to deploy code
         •   All branches are checked out on an admin server




Wednesday, September 7, 2011
Services look the same



         •   Python
         •   Java
         •   “Unix”




Wednesday, September 7, 2011
Composable




         •   Small pieces that you can build into better things
         •   Useful when trying to do something you didn’t plan for




Wednesday, September 7, 2011
Environment




Wednesday, September 7, 2011
Environment


         •   Where code lands on the remote machine
         •   Mimics a chroot
         •   Uses virtualenv & supervisord
         •   Owned by the service-user
         •   Managed by Chef




Wednesday, September 7, 2011
File Structure

         •   /mnt/services/airship
             •   bin/
             •   current -> deploy-2011-08-03_14-37-38
             •   deploy-2011-08-03_14-37-38
             •   etc/
             •   var/




Wednesday, September 7, 2011
etc/



         •   supervisord.conf
             •   [include]
             •   files = *.conf
         •   airship.conf




Wednesday, September 7, 2011
bin/



         •   start
         •   stop
         •   restart
         •   logs




Wednesday, September 7, 2011
SCRIPT_DIR=$(dirname $0)
         SERVICE_DIR=$(cd $SCRIPT_DIR && cd ../ && pwd)

         cd $SERVICE_DIR
         supervisorctl pid > /dev/null 2>&1
         if [ "$?" != "0" ]; then
              echo "Supervisord not running, starting."
              supervisord
         else
              echo "Supervisord running, starting all processes."
              supervisorctl start all
         fi
         cd - > /dev/null 2>&1




Wednesday, September 7, 2011
Bin scripts


         •   All of the process-level binscripts wrap supervisord
         •   bin/start -> supervisordctl start all
         •   bin/start foo -> supervisorctl start foo
         •   bin/stop -> supervisorctl stop all
         •   bin/stop shutdown -> supervisorctl shutdown




Wednesday, September 7, 2011
var/



         •   data/
         •   log/
         •   run/
         •   tmp/




Wednesday, September 7, 2011
Init.d



         •   All services share a common init.d script
         •   This init.d script calls into the service’s bin/
         •   /etc/init.d/airship start -> /mnt/services/airship/bin/start




Wednesday, September 7, 2011
SERVICE_USER='<%= @service %>'
         SERVICE_NAME='<%= @service %>'
         SERVICE_PATH=/mnt/services/$SERVICE_NAME
         set -e
         RET_CODE=0
         case "$1" in
              start)
                 sudo su - $SERVICE_USER -c $SERVICE_PATH/bin/start
                 RET_CODE=$?
                 ;;
              stop)
                 sudo su - $SERVICE_USER -c $SERVICE_PATH/bin/stop
                 RET_CODE=$?
                 ;;
              restart)
                 sudo su - $SERVICE_USER -c $SERVICE_PATH/bin/restart
                 RET_CODE=$?
                 ;;
              status)
                 sudo su - $SERVICE_USER -c $SERVICE_PATH/bin/status
                 RET_CODE=$?
                 ;;
              *)
                 echo "$SERVICE_NAME service usage: $0 {start|stop|restart|status}"
                 ;;
         esac

         exit $RET_CODE


Wednesday, September 7, 2011
Tools




Wednesday, September 7, 2011
Tools



         •   Fabric
         •   Rsync
         •   Pip
         •   Virtualenv




Wednesday, September 7, 2011
Low-level verbs

         •   pull
         •   build
         •   tag
         •   sync
         •   install
         •   rollback
         •   start/stop/restart/reload



Wednesday, September 7, 2011
Pull


         •   Update the code from the source repository
         •   Defaults to the “production” branch
             •   def pull(repo=None, ref='origin/production')
         •   Can pass in a specific revision/branch/tag/hashish
             •   local('git reset --hard %s' % ref, capture=False)




Wednesday, September 7, 2011
Build



         •   Could be called “prepare”
         •   Do local-specific things to get repo into a ready state
         •   Mostly used for compiling in java-land
         •   Useful in Python for running pre-install tasks




Wednesday, September 7, 2011
Tag


         •   Set a tag for the deploy in the git repo
         •   If the current commit already has a tag, use that instead
             •   git tag --contains HEAD
         •   deploy-2011-08-03_14-37-38
             •   strftime('%Y-%m-%d_%H-%M-%S')




Wednesday, September 7, 2011
Sync



         •   Move the code from the local to the remote box
         •   Uses rsync to put it into the remote service directory
         •   Also places a copy of the synced code on the admin box




Wednesday, September 7, 2011
Install



         •   Make the code the active path for code on the machine
         •   This is generally installing code into a virtualenv
         •   Updating the “current” symlink in the service directory
         •   Symlink Django settings file based on environment




Wednesday, September 7, 2011
Rollback


         •   When you break things, you need to undo quickly
         •   Reset the repository to the previous deployed tag
             •   git tag | grep deploy| sort -nr |head -2 |tail -1
         •   Deploy that
         •   Very few moving pieces




Wednesday, September 7, 2011
Start/Stop/Reload




         •   Allow you to bounce services as part of deployment
         •   Allow reload for services that support it




Wednesday, September 7, 2011
CLI UI

         •   Have nice wrapper commands that do common tasks
         •   deploy host:web-0 full_deploy:airship
             ➡ pull,           build, tag, sync, install
         •   deploy host:web-1 deploy:airship
             ➡ tag,            sync, install
         •   deploy host:web-2 sync:airship
             ➡ sync




Wednesday, September 7, 2011
UI cont.




         •   deploy host:web-0 full_deploy:airship restart:airship




Wednesday, September 7, 2011
#!/bin/bash

         cd ~/airdeploy
         DATE=$(date +%Y_%-m_%-d-%H-%m-%s)
         echo "deploy" $@ > logs/$DATE.log
         fab $@
         cd - > /dev/null 2>&1




Wednesday, September 7, 2011
Meta-commands

         •   Hard-code the correct deployment behavior
         •   “Make easy things easy, and wrong things hard”
         •   Knows what machine each service is deployed to
         •   deploy airship
             ➡ deploy          pull:airship
             ➡ deploy          type:web deploy:airship




Wednesday, September 7, 2011
Magicifying




Wednesday, September 7, 2011
Magicifying




         •   Now that we have a solid base, we can automate on top
         •   When you do a meta deploy, it should be a “smart deploy”




Wednesday, September 7, 2011
Workflow



         •   Deploy to one web server, preferably with one worker
         •   Restart it
         •   Run it against heuristics to determine if it’s broken
         •   If it’s broken, rollback, otherwise continue on




Wednesday, September 7, 2011
Heuristics

         •   Any 500s
         •   Number of 200s to non-200s
         •   Number of 500s to 200s
         •   Requests a second
         •   Response time
         •   $$$ (Business metrics)




Wednesday, September 7, 2011
How it works

         •   Tell load balancer to take machine out of pool
             •   /take_me_out_of_the_lb -> 200
         •   Start your code with 1 worker and a different port
             •   supervisorctl start canary
         •   Expose metrics from your services over json
         •   Make sure your load balancer weights it appropriately
         •   Poll your metrics for X time before considering it functional



Wednesday, September 7, 2011
Thanks



         •   Alex Kritikos
         •   Erik Onnen
         •   Schmichael




Wednesday, September 7, 2011
Questions?



         •   Eric Holscher
         •   Urban Airship (Hiring and whatnot)
         •   eric@ericholscher.com




Wednesday, September 7, 2011

More Related Content

What's hot (20)

KEY
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.
Graham Dumpleton
 
PDF
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Puppet
 
PDF
Ansible Crash Course
Peter Sankauskas
 
PDF
Puppet for SysAdmins
Puppet
 
PDF
Introduction to Ansible (Pycon7 2016)
Ivan Rossi
 
PDF
Continuous Integration Testing in Django
Kevin Harvey
 
PDF
Investigation of testing with ansible
Dennis Rowe
 
PDF
Trying Continuous Delivery - pyconjp 2012
Toru Furukawa
 
PPTX
Auto Deploy Deep Dive – vBrownBag Style
Robert Nelson
 
PDF
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Puppet
 
PDF
Tp install anything
Alessandro Franceschi
 
PDF
Modern Infrastructure from Scratch with Puppet
Puppet
 
PDF
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Puppet
 
PDF
Zero Downtime Deployment with Ansible
Stein Inge Morisbak
 
PDF
Building a Drupal site with Git
dirtytactics
 
KEY
Django Deployment with Fabric
Jonas Nockert
 
PDF
Syncing up with Python’s asyncio for (micro) service development, Joir-dan Gumbs
Pôle Systematic Paris-Region
 
PDF
Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...
Puppet
 
PDF
Workshop: Know Before You Push 'Go': Using the Beaker Acceptance Test Framewo...
Puppet
 
PDF
Test Driven Development with Puppet - PuppetConf 2014
Puppet
 
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.
Graham Dumpleton
 
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Puppet
 
Ansible Crash Course
Peter Sankauskas
 
Puppet for SysAdmins
Puppet
 
Introduction to Ansible (Pycon7 2016)
Ivan Rossi
 
Continuous Integration Testing in Django
Kevin Harvey
 
Investigation of testing with ansible
Dennis Rowe
 
Trying Continuous Delivery - pyconjp 2012
Toru Furukawa
 
Auto Deploy Deep Dive – vBrownBag Style
Robert Nelson
 
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Puppet
 
Tp install anything
Alessandro Franceschi
 
Modern Infrastructure from Scratch with Puppet
Puppet
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Puppet
 
Zero Downtime Deployment with Ansible
Stein Inge Morisbak
 
Building a Drupal site with Git
dirtytactics
 
Django Deployment with Fabric
Jonas Nockert
 
Syncing up with Python’s asyncio for (micro) service development, Joir-dan Gumbs
Pôle Systematic Paris-Region
 
Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...
Puppet
 
Workshop: Know Before You Push 'Go': Using the Beaker Acceptance Test Framewo...
Puppet
 
Test Driven Development with Puppet - PuppetConf 2014
Puppet
 

Similar to Deploying on the cutting edge (20)

PDF
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Michael Lihs
 
PDF
Continuous Integration/Deployment with Docker and Jenkins
Francesco Bruni
 
PDF
MongoDB at Sailthru: Scaling and Schema Design
DATAVERSITY
 
PDF
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
Michael Lihs
 
PPTX
DCRUG: Achieving Development-Production Parity
Geoff Harcourt
 
PDF
Deployment presentation
Corey Purcell
 
PPT
Build Automation of PHP Applications
Pavan Kumar N
 
PDF
Kuby, ActiveDeployment for Rails Apps
Cameron Dutro
 
PPTX
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
Nagios
 
PDF
Deployer - Deployment tool for PHP
hernanibf
 
PDF
Django dev-env-my-way
Robert Lujo
 
PDF
Stress Free Deployment - Confoo 2011
Bachkoutou Toutou
 
PPTX
Splunk: Forward me the REST of those shells
Anthony D Hendricks
 
PDF
Maven: from Scratch to Production (.pdf)
Johan Mynhardt
 
PDF
Installing and Getting Started with Alfresco
Wildan Maulana
 
PPTX
Continuous feature-development
nhm taveer hossain khan
 
PPTX
JavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A Cookbook
Jorge Hidalgo
 
PDF
Caridy patino - node-js
StarTech Conference
 
PDF
Conquistando el Servidor con Node.JS
Caridy Patino
 
PDF
August Webinar - Water Cooler Talks: A Look into a Developer's Workbench
Howard Greenberg
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Michael Lihs
 
Continuous Integration/Deployment with Docker and Jenkins
Francesco Bruni
 
MongoDB at Sailthru: Scaling and Schema Design
DATAVERSITY
 
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
Michael Lihs
 
DCRUG: Achieving Development-Production Parity
Geoff Harcourt
 
Deployment presentation
Corey Purcell
 
Build Automation of PHP Applications
Pavan Kumar N
 
Kuby, ActiveDeployment for Rails Apps
Cameron Dutro
 
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
Nagios
 
Deployer - Deployment tool for PHP
hernanibf
 
Django dev-env-my-way
Robert Lujo
 
Stress Free Deployment - Confoo 2011
Bachkoutou Toutou
 
Splunk: Forward me the REST of those shells
Anthony D Hendricks
 
Maven: from Scratch to Production (.pdf)
Johan Mynhardt
 
Installing and Getting Started with Alfresco
Wildan Maulana
 
Continuous feature-development
nhm taveer hossain khan
 
JavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A Cookbook
Jorge Hidalgo
 
Caridy patino - node-js
StarTech Conference
 
Conquistando el Servidor con Node.JS
Caridy Patino
 
August Webinar - Water Cooler Talks: A Look into a Developer's Workbench
Howard Greenberg
 
Ad

More from ericholscher (6)

KEY
The story and tech of Read the Docs
ericholscher
 
PDF
Read the Docs: A completely open source Django project
ericholscher
 
KEY
Read the Docs
ericholscher
 
PDF
Large problems, Mostly Solved
ericholscher
 
PDF
Token Testing Slides
ericholscher
 
PDF
Django Testing
ericholscher
 
The story and tech of Read the Docs
ericholscher
 
Read the Docs: A completely open source Django project
ericholscher
 
Read the Docs
ericholscher
 
Large problems, Mostly Solved
ericholscher
 
Token Testing Slides
ericholscher
 
Django Testing
ericholscher
 
Ad

Recently uploaded (20)

PPTX
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
PDF
Integrating IIoT with SCADA in Oil & Gas A Technical Perspective.pdf
Rejig Digital
 
PDF
Market Wrap for 18th July 2025 by CIFDAQ
CIFDAQ
 
PDF
2025-07-15 EMEA Volledig Inzicht Dutch Webinar
ThousandEyes
 
PDF
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
PDF
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
PDF
Lecture A - AI Workflows for Banking.pdf
Dr. LAM Yat-fai (林日辉)
 
PPTX
Lecture 5 - Agentic AI and model context protocol.pptx
Dr. LAM Yat-fai (林日辉)
 
PDF
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
PPTX
python advanced data structure dictionary with examples python advanced data ...
sprasanna11
 
PPTX
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
PDF
Productivity Management Software | Workstatus
Lovely Baghel
 
PDF
Ampere Offers Energy-Efficient Future For AI And Cloud
ShapeBlue
 
PDF
Alpha Altcoin Setup : TIA - 19th July 2025
CIFDAQ
 
PDF
How a Code Plagiarism Checker Protects Originality in Programming
Code Quiry
 
PDF
Shuen Mei Parth Sharma Boost Productivity, Innovation and Efficiency wit...
AWS Chicago
 
PPTX
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
 
PDF
Trading Volume Explained by CIFDAQ- Secret Of Market Trends
CIFDAQ
 
PDF
visibel.ai Company Profile – Real-Time AI Solution for CCTV
visibelaiproject
 
PDF
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
Integrating IIoT with SCADA in Oil & Gas A Technical Perspective.pdf
Rejig Digital
 
Market Wrap for 18th July 2025 by CIFDAQ
CIFDAQ
 
2025-07-15 EMEA Volledig Inzicht Dutch Webinar
ThousandEyes
 
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
Lecture A - AI Workflows for Banking.pdf
Dr. LAM Yat-fai (林日辉)
 
Lecture 5 - Agentic AI and model context protocol.pptx
Dr. LAM Yat-fai (林日辉)
 
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
python advanced data structure dictionary with examples python advanced data ...
sprasanna11
 
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
Productivity Management Software | Workstatus
Lovely Baghel
 
Ampere Offers Energy-Efficient Future For AI And Cloud
ShapeBlue
 
Alpha Altcoin Setup : TIA - 19th July 2025
CIFDAQ
 
How a Code Plagiarism Checker Protects Originality in Programming
Code Quiry
 
Shuen Mei Parth Sharma Boost Productivity, Innovation and Efficiency wit...
AWS Chicago
 
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
 
Trading Volume Explained by CIFDAQ- Secret Of Market Trends
CIFDAQ
 
visibel.ai Company Profile – Real-Time AI Solution for CCTV
visibelaiproject
 
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 

Deploying on the cutting edge

  • 1. Safely Deploying on the cutting edge Eric Holscher Urban Airship Djangocon 2011 Wednesday, September 7, 2011
  • 3. Talk Contents • Company culture & process • Deployment environment • Tools for deploying • Verifying deployment Wednesday, September 7, 2011
  • 5. Process • Deploy out of git • Standard git-based production/master branch model • Production branch has releases are tagged with timestamp • deploy-2011-08-03_14-37-38 • Feature branches • http://nvie.com/posts/a-successful-git-branching-model/ Wednesday, September 7, 2011
  • 6. Features • Easily allows you to hot-fix production • Keep a stable master • Run CI on the master branch or long-lived feature branches Wednesday, September 7, 2011
  • 7. Services • Everything that we deploy is conceptualized as a service • Services all live in /mnt/services/<slug> (Thanks ec2) • A service is an instance of a repository on a machine • A repository might have multiple services • eg. Airship deployed into “celery” and “web” services • This maps really well onto Chef cookbooks Wednesday, September 7, 2011
  • 8. QA Environment • Run all of your master branches • Allow you to get a copy of what will become production • Catch errors before they are seen by customers • Spawn new ones for long-lived feature branches • `host web-0` and figure out based on IP Wednesday, September 7, 2011
  • 10. Jump machine • Have a standard place for all deployments to happen • Log all commands run Wednesday, September 7, 2011
  • 11. No External Services • Chishop • No external server required to deploy code • All branches are checked out on an admin server Wednesday, September 7, 2011
  • 12. Services look the same • Python • Java • “Unix” Wednesday, September 7, 2011
  • 13. Composable • Small pieces that you can build into better things • Useful when trying to do something you didn’t plan for Wednesday, September 7, 2011
  • 15. Environment • Where code lands on the remote machine • Mimics a chroot • Uses virtualenv & supervisord • Owned by the service-user • Managed by Chef Wednesday, September 7, 2011
  • 16. File Structure • /mnt/services/airship • bin/ • current -> deploy-2011-08-03_14-37-38 • deploy-2011-08-03_14-37-38 • etc/ • var/ Wednesday, September 7, 2011
  • 17. etc/ • supervisord.conf • [include] • files = *.conf • airship.conf Wednesday, September 7, 2011
  • 18. bin/ • start • stop • restart • logs Wednesday, September 7, 2011
  • 19. SCRIPT_DIR=$(dirname $0) SERVICE_DIR=$(cd $SCRIPT_DIR && cd ../ && pwd) cd $SERVICE_DIR supervisorctl pid > /dev/null 2>&1 if [ "$?" != "0" ]; then echo "Supervisord not running, starting." supervisord else echo "Supervisord running, starting all processes." supervisorctl start all fi cd - > /dev/null 2>&1 Wednesday, September 7, 2011
  • 20. Bin scripts • All of the process-level binscripts wrap supervisord • bin/start -> supervisordctl start all • bin/start foo -> supervisorctl start foo • bin/stop -> supervisorctl stop all • bin/stop shutdown -> supervisorctl shutdown Wednesday, September 7, 2011
  • 21. var/ • data/ • log/ • run/ • tmp/ Wednesday, September 7, 2011
  • 22. Init.d • All services share a common init.d script • This init.d script calls into the service’s bin/ • /etc/init.d/airship start -> /mnt/services/airship/bin/start Wednesday, September 7, 2011
  • 23. SERVICE_USER='<%= @service %>' SERVICE_NAME='<%= @service %>' SERVICE_PATH=/mnt/services/$SERVICE_NAME set -e RET_CODE=0 case "$1" in start) sudo su - $SERVICE_USER -c $SERVICE_PATH/bin/start RET_CODE=$? ;; stop) sudo su - $SERVICE_USER -c $SERVICE_PATH/bin/stop RET_CODE=$? ;; restart) sudo su - $SERVICE_USER -c $SERVICE_PATH/bin/restart RET_CODE=$? ;; status) sudo su - $SERVICE_USER -c $SERVICE_PATH/bin/status RET_CODE=$? ;; *) echo "$SERVICE_NAME service usage: $0 {start|stop|restart|status}" ;; esac exit $RET_CODE Wednesday, September 7, 2011
  • 25. Tools • Fabric • Rsync • Pip • Virtualenv Wednesday, September 7, 2011
  • 26. Low-level verbs • pull • build • tag • sync • install • rollback • start/stop/restart/reload Wednesday, September 7, 2011
  • 27. Pull • Update the code from the source repository • Defaults to the “production” branch • def pull(repo=None, ref='origin/production') • Can pass in a specific revision/branch/tag/hashish • local('git reset --hard %s' % ref, capture=False) Wednesday, September 7, 2011
  • 28. Build • Could be called “prepare” • Do local-specific things to get repo into a ready state • Mostly used for compiling in java-land • Useful in Python for running pre-install tasks Wednesday, September 7, 2011
  • 29. Tag • Set a tag for the deploy in the git repo • If the current commit already has a tag, use that instead • git tag --contains HEAD • deploy-2011-08-03_14-37-38 • strftime('%Y-%m-%d_%H-%M-%S') Wednesday, September 7, 2011
  • 30. Sync • Move the code from the local to the remote box • Uses rsync to put it into the remote service directory • Also places a copy of the synced code on the admin box Wednesday, September 7, 2011
  • 31. Install • Make the code the active path for code on the machine • This is generally installing code into a virtualenv • Updating the “current” symlink in the service directory • Symlink Django settings file based on environment Wednesday, September 7, 2011
  • 32. Rollback • When you break things, you need to undo quickly • Reset the repository to the previous deployed tag • git tag | grep deploy| sort -nr |head -2 |tail -1 • Deploy that • Very few moving pieces Wednesday, September 7, 2011
  • 33. Start/Stop/Reload • Allow you to bounce services as part of deployment • Allow reload for services that support it Wednesday, September 7, 2011
  • 34. CLI UI • Have nice wrapper commands that do common tasks • deploy host:web-0 full_deploy:airship ➡ pull, build, tag, sync, install • deploy host:web-1 deploy:airship ➡ tag, sync, install • deploy host:web-2 sync:airship ➡ sync Wednesday, September 7, 2011
  • 35. UI cont. • deploy host:web-0 full_deploy:airship restart:airship Wednesday, September 7, 2011
  • 36. #!/bin/bash cd ~/airdeploy DATE=$(date +%Y_%-m_%-d-%H-%m-%s) echo "deploy" $@ > logs/$DATE.log fab $@ cd - > /dev/null 2>&1 Wednesday, September 7, 2011
  • 37. Meta-commands • Hard-code the correct deployment behavior • “Make easy things easy, and wrong things hard” • Knows what machine each service is deployed to • deploy airship ➡ deploy pull:airship ➡ deploy type:web deploy:airship Wednesday, September 7, 2011
  • 39. Magicifying • Now that we have a solid base, we can automate on top • When you do a meta deploy, it should be a “smart deploy” Wednesday, September 7, 2011
  • 40. Workflow • Deploy to one web server, preferably with one worker • Restart it • Run it against heuristics to determine if it’s broken • If it’s broken, rollback, otherwise continue on Wednesday, September 7, 2011
  • 41. Heuristics • Any 500s • Number of 200s to non-200s • Number of 500s to 200s • Requests a second • Response time • $$$ (Business metrics) Wednesday, September 7, 2011
  • 42. How it works • Tell load balancer to take machine out of pool • /take_me_out_of_the_lb -> 200 • Start your code with 1 worker and a different port • supervisorctl start canary • Expose metrics from your services over json • Make sure your load balancer weights it appropriately • Poll your metrics for X time before considering it functional Wednesday, September 7, 2011
  • 43. Thanks • Alex Kritikos • Erik Onnen • Schmichael Wednesday, September 7, 2011
  • 44. Questions? • Eric Holscher • Urban Airship (Hiring and whatnot) • [email protected] Wednesday, September 7, 2011

Editor's Notes