Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Keith and Mario's Guide to Continuous Deployment

Keith Pitt
February 22, 2014

Keith and Mario's Guide to Continuous Deployment

This is a presentation that @mariovisic (http://twitter.com/mariovisic) and I (http://twitter.com/keithpitt) performed at RubyConf Australia, 2014.

Recently it has become common practise for development teams to deploy their code several times a day, as well as encouraging new developers to deploy on their first day at work.

In our talk Mario and I will discussed how we used continuous deployment to push these practises to the extreme. Automatically deploying the master branch on new changes is an awesome way to improve your development process.

Automatically deploying master will fundamentally change how you work. Gone are the days of the epic pull request. You'll quickly find yourself writing smaller more manageable chunks of code, that overall have a great impact on the quality of the software you produce.

By the end of the talk you'll know how to change the GitHub merge pull request button into a deploy button - and have the confidence to do so.

Some things we'll go over in the talk:

- How to setup your CI environment for deployments
- Why having fast tests are important
- How to use your Staging environment for testing deployments
- How to use feature flags to hide deployed features from some users
- Zero downtime deploys, even when there are database migrations
- Your new deploy button, AKA The GitHub merge pull request button
- What to do when deployment goes wrong

Proposal: https://github.com/keithpitt/rubyconfau-2014-cfp/tree/master/keith-and-marios-guide-to-continuous-deployment

Keith Pitt

February 22, 2014
Tweet

More Decks by Keith Pitt

Other Decks in Programming

Transcript

  1. CONTINUOUS DEPLOYMENT
    Keith & Mario’s Guide To
    @keithpitt @mariovisic
    OR
    Why automatically deploying your master branch
    to production is a good idea.

    View Slide

  2. Keith and Mario’s Guide to
    FAST WEBSITES
    @keithpitt @mariovisic
    Previously…

    View Slide

  3. View Slide

  4. View Slide

  5. View Slide

  6. View Slide

  7. View Slide

  8. View Slide

  9. View Slide

  10. View Slide

  11. View Slide

  12. View Slide

  13. View Slide

  14. View Slide

  15. View Slide

  16. View Slide

  17. View Slide

  18. microlancer

    View Slide

  19. Desktoppr

    View Slide

  20. View Slide

  21. ALRIGHT, LISTEN UP

    View Slide

  22. View Slide

  23. View Slide

  24. WHY CONTINUOUS
    DEPLOYMENT?

    View Slide

  25. FAST FEEDBACK
    CONFIDENCE PREDICTABILITY

    View Slide

  26. INGREDIENTS

    View Slide

  27. INGREDIENTS
    Feature Planning!
    Code Reviews!
    Feature Toggles!
    Automated Tests!
    Smoke Tests!
    Zero Downtime Deploys!
    Rollback Strategy!
    Handling Database Migrations!
    Application Monitoring

    View Slide

  28. !
    FEATURE PLANNING

    View Slide

  29. SMALLEST THING THAT
    YOU CAN SHIP TODAY
    Feature Planning

    View Slide

  30. HOW DO YOU DEPLOY IT
    WITH ZERO DOWNTIME?
    Feature Planning

    View Slide

  31. HOW WILL WE HANDLE
    DATABASE MIGRATIONS?
    Feature Planning

    View Slide

  32. CODE REVIEWS

    View Slide

  33. GITHUB PULL REQUESTS
    Reviewing Code

    View Slide

  34. View Slide

  35. GITHUB.COM/SQUARE/CANE
    Reviewing Code

    View Slide

  36. GITHUB.COM/BBATSOV/RUBOCOP
    Reviewing Code

    View Slide

  37. FEATURE TOGGLES

    View Slide

  38. KEEP IT GHETTO
    Feature Toggles

    View Slide

  39. Feature Toggles
    GITHUB.COM/FETLIFE/ROLLOUT

    View Slide

  40. Feature Toggles
    GITHUB.COM/PDA/FLIP

    View Slide

  41. AUTOMATED TESTS

    View Slide

  42. WRITE JUST ENOUGH TESTS
    TO TRUST THE CODE
    Automated Tests

    View Slide

  43. SO THEY’RE FAST
    Automated Tests

    View Slide

  44. COREY HAINES FAST RAILS TESTS
    Automated Tests

    View Slide

  45. SMOKE TESTS

    View Slide

  46. RUNS POST DEPLOY
    AGAINST REMOTE SERVER
    Smoke Tests

    View Slide

  47. BONUS POINTS: THE SAME
    TESTS RUN AGAINST
    REMOTE SERVER & LOCAL
    Smoke Tests

    View Slide

  48. ZERO DOWNTIME DEPLOYS

    View Slide

  49. DEPLOYING NEW CODE
    WITHOUT MAINTENANCE
    PAGE
    Zero Downtime Deploys

    View Slide

  50. HEROKU PRO TIP:
    HEROKU LABS:ENABLE PREBOOT
    Zero Downtime Deploys

    View Slide

  51. RAILSCASTS TUTORIAL
    Zero Downtime Deploys

    View Slide

  52. DATABASE MIGRATIONS

    View Slide

  53. HARDEST PART
    Database Migrations

    View Slide

  54. View Slide

  55. PGError: ERROR: column "notes" does not exist

    View Slide

  56. EASY WAY:
    MAINTENANCE PAGE
    Database Migrations

    View Slide

  57. HARD WAY: DEPLOY
    MIGRATIONS FIRST
    Database Migrations

    View Slide

  58. Database Migrations
    PEDRO BELO ARTICLE

    View Slide

  59. BEWARE OF DATABASE
    LOCKING
    Database Migrations

    View Slide

  60. Database Migrations
    GITHUB.COM/SOUNDCLOUD/LHM

    View Slide

  61. ROLLING BACK DEPLOYS

    View Slide

  62. JUST ROLL FORWARD
    Rolling Back Deploys

    View Slide

  63. JUST TURN THE
    FEATURE OFF
    Rolling Back Deploys

    View Slide

  64. IF YOU HAVE TO:
    GIT REVERT AND DEPLOY
    Rolling Back Deploys

    View Slide

  65. BEAR GRYLLS
    WORST CASE SCENARIO

    View Slide

  66. TURN ON
    MAINTENANCE PAGE
    Rolling Back Deploys

    View Slide

  67. APPLICATION MONITORING

    View Slide

  68. EXCEPTION TRACKING
    Application Monitoring

    View Slide

  69. PERFORMANCE MONITORING
    Application Monitoring

    View Slide

  70. DAVID GOODLAD BUSINESS METRIC MONITORING
    Application Monitoring

    View Slide

  71. GETTING NOTIFIED
    Application Monitoring

    View Slide

  72. INGREDIENTS
    Feature Planning!
    Code Reviews!
    Feature Toggles!
    Automated Tests!
    Smoke Tests!
    Zero Downtime Deploys!
    Rollback Strategy!
    Handling Database Migrations!
    Application Monitoring

    View Slide

  73. TIME TO MIX

    View Slide

  74. View Slide

  75. View Slide

  76. View Slide

  77. THE FINAL PRODUCT

    View Slide

  78. View Slide

  79. View Slide

  80. View Slide

  81. View Slide

  82. View Slide

  83. View Slide

  84. View Slide

  85. View Slide

  86. View Slide

  87. View Slide

  88. View Slide

  89. View Slide

  90. View Slide

  91. View Slide

  92. FAST FEEDBACK
    CONFIDENCE PREDICTABILITY

    View Slide

  93. FAST FEEDBACK
    CONFIDENCE
    PREDICTABILITY



    View Slide

  94. AVERAGE NUMBER OF DEPLOYS PER DAY
    Manual!
    Deploys
    Continuous!
    Deploys

    View Slide

  95. AVERAGE NUMBER OF DEPLOYS PER DAY
    1.9
    4.7
    130 Additions!
    Per Deploy
    245 Additions!
    Per Deploy
    Manual!
    Deploys
    Continuous!
    Deploys

    View Slide

  96. View Slide

  97. CONTINUOUS DEPLOYMENT
    Keith & Mario’s Guide To
    @keithpitt @mariovisic
    FIN.

    View Slide