Keith and Mario's Guide to Continuous Deployment

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

E14f55d3f939977cecbf51b64ff6f861?s=128

Keith Pitt

February 22, 2014
Tweet

Transcript

  1. CONTINUOUS DEPLOYMENT Keith & Mario’s Guide To @keithpitt @mariovisic OR

    Why automatically deploying your master branch to production is a good idea.
  2. Keith and Mario’s Guide to FAST WEBSITES @keithpitt @mariovisic Previously…

  3. None
  4. None
  5. None
  6. None
  7. None
  8. None
  9. None
  10. None
  11. None
  12. None
  13. None
  14. None
  15. None
  16. None
  17. None
  18. microlancer

  19. Desktoppr

  20. None
  21. ALRIGHT, LISTEN UP

  22. None
  23. None
  24. WHY CONTINUOUS DEPLOYMENT?

  25. FAST FEEDBACK CONFIDENCE PREDICTABILITY

  26. INGREDIENTS

  27. INGREDIENTS Feature Planning! Code Reviews! Feature Toggles! Automated Tests! Smoke

    Tests! Zero Downtime Deploys! Rollback Strategy! Handling Database Migrations! Application Monitoring
  28. ! FEATURE PLANNING

  29. SMALLEST THING THAT YOU CAN SHIP TODAY Feature Planning

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

  31. HOW WILL WE HANDLE DATABASE MIGRATIONS? Feature Planning

  32. CODE REVIEWS

  33. GITHUB PULL REQUESTS Reviewing Code

  34. None
  35. GITHUB.COM/SQUARE/CANE Reviewing Code

  36. GITHUB.COM/BBATSOV/RUBOCOP Reviewing Code

  37. FEATURE TOGGLES

  38. KEEP IT GHETTO Feature Toggles

  39. Feature Toggles GITHUB.COM/FETLIFE/ROLLOUT

  40. Feature Toggles GITHUB.COM/PDA/FLIP

  41. AUTOMATED TESTS

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

  43. SO THEY’RE FAST Automated Tests

  44. COREY HAINES FAST RAILS TESTS Automated Tests

  45. SMOKE TESTS

  46. RUNS POST DEPLOY AGAINST REMOTE SERVER Smoke Tests

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

    LOCAL Smoke Tests
  48. ZERO DOWNTIME DEPLOYS

  49. DEPLOYING NEW CODE WITHOUT MAINTENANCE PAGE Zero Downtime Deploys

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

  51. RAILSCASTS TUTORIAL Zero Downtime Deploys

  52. DATABASE MIGRATIONS

  53. HARDEST PART Database Migrations

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

  56. EASY WAY: MAINTENANCE PAGE Database Migrations

  57. HARD WAY: DEPLOY MIGRATIONS FIRST Database Migrations

  58. Database Migrations PEDRO BELO ARTICLE

  59. BEWARE OF DATABASE LOCKING Database Migrations

  60. Database Migrations GITHUB.COM/SOUNDCLOUD/LHM

  61. ROLLING BACK DEPLOYS

  62. JUST ROLL FORWARD Rolling Back Deploys

  63. JUST TURN THE FEATURE OFF Rolling Back Deploys

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

    Deploys
  65. BEAR GRYLLS WORST CASE SCENARIO

  66. TURN ON MAINTENANCE PAGE Rolling Back Deploys

  67. APPLICATION MONITORING

  68. EXCEPTION TRACKING Application Monitoring

  69. PERFORMANCE MONITORING Application Monitoring

  70. DAVID GOODLAD BUSINESS METRIC MONITORING Application Monitoring

  71. GETTING NOTIFIED Application Monitoring

  72. INGREDIENTS Feature Planning! Code Reviews! Feature Toggles! Automated Tests! Smoke

    Tests! Zero Downtime Deploys! Rollback Strategy! Handling Database Migrations! Application Monitoring
  73. TIME TO MIX

  74. None
  75. None
  76. None
  77. THE FINAL PRODUCT

  78. None
  79. None
  80. None
  81. None
  82. None
  83. None
  84. None
  85. None
  86. None
  87. None
  88. None
  89. None
  90. None
  91. None
  92. FAST FEEDBACK CONFIDENCE PREDICTABILITY

  93. FAST FEEDBACK CONFIDENCE PREDICTABILITY ✔ ✔ ✔

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

  95. AVERAGE NUMBER OF DEPLOYS PER DAY 1.9 4.7 130 Additions!

    Per Deploy 245 Additions! Per Deploy Manual! Deploys Continuous! Deploys
  96. None
  97. CONTINUOUS DEPLOYMENT Keith & Mario’s Guide To @keithpitt @mariovisic FIN.