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

[2018.04 Meetup][TALK] Dave Farley - Optimising...

[2018.04 Meetup][TALK] Dave Farley - Optimising Continuous Delivery

Talk: Optimising Continuous Delivery
Speaker: Dave Farley (@davefarley77)

The deployment pipeline is a central idea in Continuous Delivery. It represents the channel through which ideas inside your business flow to the outside world so that they can be delivered to your users in the form of working software. First steps in creating a working deployment pipeline are very rewarding. They help to improve the quality of the software that you create and usually lead to happier users.

As teams mature in their adoption of Continuous Delivery though, the pipeline often begins to slow. We have more tests, we are testing more complex things, our software becomes more complex and more difficult to deploy.

How do we address these growing pains? What are the next steps, beyond the CD beginner’s basic automation? How do we optimise our pipelines to meet our needs as these needs grow?

This talk will address the growing pains in Continuous Delivery and describe some strategies to cope with them.

Dave Farley is the co-author of the Jolt-award winning book ‘Continuous Delivery’ a regular conference speaker and blogger and a contributor to the Reactive Manifesto. Dave is an independent software developer and consultant, and founder and director of Continuous Delivery Ltd.

DevOps Lisbon

April 16, 2018
Tweet

More Decks by DevOps Lisbon

Other Decks in Technology

Transcript

  1. What Really Works? Smart Automation - a repeatable, reliable process

    for releasing software Unit Test Code Idea Executable spec. Build Release
  2. What Really Works? Smart Automation - a repeatable, reliable process

    for releasing software Unit Test Code Idea Executable spec. Build Release
  3. What Really Works? Smart Automation - a repeatable, reliable process

    for releasing software Unit Test Code Idea Executable spec. Build Release “It doesn’t matter how intelligent you are, if you guess and that guess cannot be backed up by experimental evidence – then it is still a guess!” - Richard Feynman
  4. Cycle Time Commit Stage Compile Unit test Analysis Build Installers

    Automated acceptance testing Automated performance testing Manual testing Release 57 mins 3 mins 20 mins 20 mins 30 mins 4 mins Typical CD Cycle Time 103 days Typical Traditional Cycle Time 10 days 64 days
  5. The Principles of Continuous Delivery Create a repeatable, reliable process

    for releasing software. Automate almost everything.
  6. The Principles of Continuous Delivery Create a repeatable, reliable process

    for releasing software. Automate almost everything. Keep everything under version control.
  7. The Principles of Continuous Delivery Create a repeatable, reliable process

    for releasing software. Automate almost everything. Keep everything under version control. If it hurts, do it more often – bring the pain forward.
  8. The Principles of Continuous Delivery Create a repeatable, reliable process

    for releasing software. Automate almost everything. Keep everything under version control. If it hurts, do it more often – bring the pain forward. Build quality in.
  9. The Principles of Continuous Delivery Create a repeatable, reliable process

    for releasing software. Automate almost everything. Keep everything under version control. If it hurts, do it more often – bring the pain forward. Build quality in. Done means released.
  10. The Principles of Continuous Delivery Create a repeatable, reliable process

    for releasing software. Automate almost everything. Keep everything under version control. If it hurts, do it more often – bring the pain forward. Build quality in. Done means released. Everybody is responsible for the release process.
  11. The Principles of Continuous Delivery Create a repeatable, reliable process

    for releasing software. Automate almost everything. Keep everything under version control. If it hurts, do it more often – bring the pain forward. Build quality in. Done means released. Everybody is responsible for the release process. Improve continuously.
  12. Basic Continuous Delivery Process Artifact Repository Local Dev. Env. Acceptance

    Commit Production Env. Deployment App. Commit Acceptance Source Repository
  13. Basic Continuous Delivery Process Artifact Repository Local Dev. Env. Acceptance

    Commit Production Env. Deployment App. Commit Acceptance Source Repository
  14. Basic Continuous Delivery Process Artifact Repository Local Dev. Env. Acceptance

    Commit Production Env. Deployment App. Commit Acceptance Production Source Repository
  15. Basic Continuous Delivery Process Artifact Repository Local Dev. Env. Deployment

    Pipeline Acceptance Commit Production Env. Deployment App. Commit Acceptance Production Source Repository
  16. Example Continuous Delivery Process Artifact Repository Local Dev. Env. Acceptance

    Commit Commit Acceptance Manual Source Repository Manual Test Env. Deployment App.
  17. Example Continuous Delivery Process Artifact Repository Local Dev. Env. Acceptance

    Commit Component Performance Commit Acceptance Manual Perf1 Source Repository Manual Test Env. Deployment App.
  18. Example Continuous Delivery Process Artifact Repository Local Dev. Env. Acceptance

    Commit Component Performance System Performance Commit Acceptance Manual Perf1 Perf2 Source Repository Manual Test Env. Deployment App.
  19. Example Continuous Delivery Process Artifact Repository Local Dev. Env. Acceptance

    Commit Component Performance System Performance Commit Acceptance Manual Perf1 Perf2 Staged Source Repository Manual Test Env. Deployment App. Data Migration
  20. Example Continuous Delivery Process Artifact Repository Local Dev. Env. Deployment

    Pipeline Acceptance Commit Component Performance System Performance Production Env. Deployment App. Commit Acceptance Manual Perf1 Perf2 Staged Production Source Repository Manual Test Env. Deployment App. Data Migration
  21. The Pipeline is a Strategic Resource • It is the

    only channel to production • All change in production flows through it • So if it breaks or goes slow, the impact is enormous
  22. Pipeline Problems • Slow Commit Stage • Slow Acceptance Stage

    • Failing Tests • Intermittent Tests • Pipeline Changes
  23. Pipeline Problems • Slow Commit Stage • Slow Acceptance Stage

    • Failing Tests • Intermittent Tests • Pipeline Changes
  24. (C)opyright Dave Farley 2015 Local Dev. Env. Slow Commit Stage

    Artifact Repository Deployment Pipeline Acceptance Component Performance System Performance Production Env. Deployment App. Commit Acceptance Manual Perf1 Perf2 Staged Production Manual Test Env. Deployment App. Data Migration Source Repository Commit
  25. (C)opyright Dave Farley 2015 Local Dev. Env. Slow Commit Stage

    Artifact Repository Deployment Pipeline Acceptance Component Performance System Performance Production Env. Deployment App. Commit Acceptance Manual Perf1 Perf2 Staged Production Manual Test Env. Deployment App. Data Migration Source Repository Commit
  26. (C)opyright Dave Farley 2015 Local Dev. Env. Slow Commit Stage

    Artifact Repository Deployment Pipeline Acceptance Component Performance System Performance Production Env. Deployment App. Commit Acceptance Manual Perf1 Perf2 Staged Production Manual Test Env. Deployment App. Data Migration Source Repository Commit Commit Stage Compile Unit Test Analysis Build Installers
  27. (C)opyright Dave Farley 2015 Local Dev. Env. Slow Commit Stage

    Artifact Repository Deployment Pipeline Acceptance Component Performance System Performance Production Env. Deployment App. Commit Acceptance Manual Perf1 Perf2 Staged Production Manual Test Env. Deployment App. Data Migration Source Repository Commit Commit Stage Compile Unit Test Analysis Build Installers Ideal Feedback Cycle for this stage: < 5min
  28. (C)opyright Dave Farley 2015 Local Dev. Env. Slow Commit Stage

    Artifact Repository Deployment Pipeline Acceptance Component Performance System Performance Production Env. Deployment App. Commit Acceptance Manual Perf1 Perf2 Staged Production Manual Test Env. Deployment App. Data Migration Source Repository Commit
  29. (C)opyright Dave Farley 2015 Local Dev. Env. Slow Commit Stage

    Artifact Repository Deployment Pipeline Acceptance Component Performance System Performance Production Env. Deployment App. Commit Acceptance Manual Perf1 Perf2 Staged Production Manual Test Env. Deployment App. Data Migration Source Repository Commit This is the most valuable Feedback-Cycle in the Pipeline!
  30. (C)opyright Dave Farley 2015 Local Dev. Env. Slow Commit Stage

    Artifact Repository Deployment Pipeline Acceptance Component Performance System Performance Production Env. Deployment App. Commit Acceptance Manual Perf1 Perf2 Staged Production Manual Test Env. Deployment App. Data Migration Source Repository Commit This is the most valuable Feedback-Cycle in the Pipeline! Invest Time, Effort & Money
  31. Slow Commit Stage - Compilation Decompose your system into independent

    modules or services
 Each with it’s own pipeline
  32. Slow Commit Stage - Compilation Decompose your system into independent

    modules or services
 Each with it’s own pipeline
  33. Slow Commit Stage - Compilation Decompose your system into independent

    modules or services
 Each with it’s own pipeline WARNING!!! This is not as easy as it first seems Dependency Management is one of the really problems in Computer Science! HARD Microservices is no “Silver Bullet” Remember: “Independently Deployable Units”
  34. Slow Commit Stage - Compilation Decompose your system into independent

    modules or services
 Each with it’s own pipeline
  35. Slow Commit Stage - Compilation Try running the build from

    RAM Disk
 Good for I/O bound compilation cycles (e.g. C, C++)
  36. Slow Commit Stage - Testing Commit tests should be mostly

    pure unit tests Don’t Start the app! Don’t Write to Disk! Don’t Write to the DB! Don’t Use the Network! Fake External Dependencies!
  37. Slow Commit Stage - Testing Always think about efficiency when

    writing tests • Use Chicken Counting (0, 1, Many) • Use Mocks & Stubs
  38. Slow Commit Stage - Testing Periodically: Sort your tests by

    duration and speed-up the slowest 10%
  39. Slow Commit Stage - Testing Run Tests in Parallel •

    If this is difficult, your test isolation is poor - fix it!
  40. Slow Commit Stage - Testing Last Resort: 
 Move slow,

    problematic but high-value tests to a later stage in the pipeline
  41. Slow Commit Stage - Analysis It needs to pay for

    itself though. If the analysis doesn’t catch bugs, drop it!
  42. Slow Commit Stage - Installers We want to test Release

    Candidates that may make it to production
  43. Slow Commit Stage - Installers The output of a successful

    commit stage is production deployable software
  44. Slow Commit Stage - Installers If creating installers is slow,

    move it out of Commit Stage
 This is fine because creating installers is not usually a source of errors
  45. (C)opyright Dave Farley 2016 Human CI • Always run Commit

    Tests locally before committing • Wait for result of Commit Build
  46. (C)opyright Dave Farley 2016 Human CI • Always run Commit

    Tests locally before committing • Wait for result of Commit Build • Don’t Go Home, To Lunch, To a Meeting, To Make Coffee…
  47. (C)opyright Dave Farley 2016 Human CI • Always run Commit

    Tests locally before committing • Wait for result of Commit Build • Don’t Go Home, To Lunch, To a Meeting, To Make Coffee… • Fix or Revert Failures within 10 minutes
  48. (C)opyright Dave Farley 2016 Human CI • Always run Commit

    Tests locally before committing • Wait for result of Commit Build • Don’t Go Home, To Lunch, To a Meeting, To Make Coffee… • Fix or Revert Failures within 10 minutes • If a Team Mate as “Gone Home”, “Gone to Lunch” etc. Revert their change
  49. (C)opyright Dave Farley 2016 Human CI • Always run Commit

    Tests locally before committing • Wait for result of Commit Build • Don’t Go Home, To Lunch, To a Meeting, To Make Coffee… • Fix or Revert Failures within 10 minutes • If a Team Mate as “Gone Home”, “Gone to Lunch” etc. Revert their change • If someone else notices that you broke the build before you do, it is a sin!
  50. (C)opyright Dave Farley 2016 Human CI • Always run Commit

    Tests locally before committing • Wait for result of Commit Build • Don’t Go Home, To Lunch, To a Meeting, To Make Coffee… • Fix or Revert Failures within 10 minutes • If a Team Mate as “Gone Home”, “Gone to Lunch” etc. Revert their change • If someone else notices that you broke the build before you do, it is a sin! • Once the Commit Stage passes, move on to your next task
  51. (C)opyright Dave Farley 2016 Human CI • Always run Commit

    Tests locally before committing • Wait for result of Commit Build • Don’t Go Home, To Lunch, To a Meeting, To Make Coffee… • Fix or Revert Failures within 10 minutes • If a Team Mate as “Gone Home”, “Gone to Lunch” etc. Revert their change • If someone else notices that you broke the build before you do, it is a sin! • Once the Commit Stage passes, move on to your next task • Monitor the progress of your change through the pipeline.
  52. (C)opyright Dave Farley 2016 Human CI • Always run Commit

    Tests locally before committing • Wait for result of Commit Build • Don’t Go Home, To Lunch, To a Meeting, To Make Coffee… • Fix or Revert Failures within 10 minutes • If a Team Mate as “Gone Home”, “Gone to Lunch” etc. Revert their change • If someone else notices that you broke the build before you do, it is a sin! • Once the Commit Stage passes, move on to your next task • Monitor the progress of your change through the pipeline. • If a later stage fails, address the failure immediately
  53. (C)opyright Dave Farley 2016 Human CI • Always run Commit

    Tests locally before committing • Wait for result of Commit Build • Don’t Go Home, To Lunch, To a Meeting, To Make Coffee… • Fix or Revert Failures within 10 minutes • If a Team Mate as “Gone Home”, “Gone to Lunch” etc. Revert their change • If someone else notices that you broke the build before you do, it is a sin! • Once the Commit Stage passes, move on to your next task • Monitor the progress of your change through the pipeline. • If a later stage fails, address the failure immediately CD is about optimising your process to keep the software in a releasable state That means pipeline failures are top priority!
  54. (C)opyright Dave Farley 2015 Commit Strategies Artifact Repository Commit Source

    Repository Commit Local Dev. Env. Artifact Repository Source Repository Commit Local Dev. Env. Commit Pass? Human CI
  55. (C)opyright Dave Farley 2015 Commit Strategies Artifact Repository Commit Source

    Repository Commit Local Dev. Env. Artifact Repository Source Repository Commit Local Dev. Env. Commit Pass? Human CI Gated/Pre-Commit CI
  56. Slow Commit Stage - Summary • Performance of the Commit

    Stage Matters • Teams with a fast Commit Stage keep the build green • Commit Stage performance as an important thing. Invest in it!
  57. Pipeline Problems • Slow Commit Stage • Slow Acceptance Stage

    • Failing Tests • Intermittent Tests • Pipeline Changes
  58. Pipeline Problems • Slow Commit Stage • Slow Acceptance Stage

    • Failing Tests • Intermittent Tests • Pipeline Changes
  59. (C)opyright Dave Farley 2015 Local Dev. Env. Artifact Repository Deployment

    Pipeline Component Performance System Performance Production Env. Deployment App. Commit Acceptance Manual Perf1 Perf2 Staged Production Manual Test Env. Deployment App. Data Migration Source Repository Commit Acceptance Slow Acceptance Stage
  60. (C)opyright Dave Farley 2015 Local Dev. Env. Artifact Repository Deployment

    Pipeline Component Performance System Performance Production Env. Deployment App. Commit Acceptance Manual Perf1 Perf2 Staged Production Manual Test Env. Deployment App. Data Migration Source Repository Commit Acceptance Slow Acceptance Stage
  61. (C)opyright Dave Farley 2015 Local Dev. Env. Artifact Repository Deployment

    Pipeline Component Performance System Performance Production Env. Deployment App. Commit Acceptance Manual Perf1 Perf2 Staged Production Manual Test Env. Deployment App. Data Migration Source Repository Commit Acceptance Acceptance Stage Configure Environment Deploy Release Candidate Smoke Test/Health Check Acceptance Test Slow Acceptance Stage
  62. (C)opyright Dave Farley 2015 Local Dev. Env. Artifact Repository Deployment

    Pipeline Component Performance System Performance Production Env. Deployment App. Commit Acceptance Manual Perf1 Perf2 Staged Production Manual Test Env. Deployment App. Data Migration Source Repository Commit Acceptance Acceptance Stage Configure Environment Deploy Release Candidate Smoke Test/Health Check Acceptance Test Slow Acceptance Stage Ideal Feedback Cycle for this stage: < 45min
  63. Slow Acceptance Stage - Configure Env. Consider rates of change

    of different layers
 (e.g. OS changes less often than the app)
  64. Slow Acceptance Stage - Deploy • Successful Deployment ends with

    a running, working system • So for efficiency we need to consider:
  65. Slow Acceptance Stage - Deploy • Successful Deployment ends with

    a running, working system • So for efficiency we need to consider: • Time to Deploy
  66. Slow Acceptance Stage - Deploy • Successful Deployment ends with

    a running, working system • So for efficiency we need to consider: • Time to Deploy • Time to Migrate Data
  67. Slow Acceptance Stage - Deploy • Successful Deployment ends with

    a running, working system • So for efficiency we need to consider: • Time to Deploy • Time to Migrate Data • Time to Start the System
  68. Slow Acceptance Stage - Deploy • Successful Deployment ends with

    a running, working system • So for efficiency we need to consider: • Time to Deploy • Time to Migrate Data • Time to Start the System • Time to Validate the System
  69. Slow Acceptance Stage - Deploy Time To Deploy: • Keep

    deployable artefacts lean • Packaging strategy can make a big difference
  70. Slow Acceptance Stage - Deploy Time To Deploy: • Keep

    deployable artefacts lean • Packaging strategy can make a big difference • Think about network/infrastructure constraints at deployment time
  71. Slow Acceptance Stage - Deploy Time To Deploy: • Keep

    deployable artefacts lean • Packaging strategy can make a big difference • Think about network/infrastructure constraints at deployment time • Minimise data-sets, where you can
  72. Slow Acceptance Stage - Deploy Time To Deploy: • Keep

    deployable artefacts lean • Packaging strategy can make a big difference • Think about network/infrastructure constraints at deployment time • Minimise data-sets, where you can • Consider better modularisation - Independently deployable services
  73. Slow Acceptance Stage - Deploy Time To Start the System:

    • Minimise Start-up dependencies & ordering
  74. Slow Acceptance Stage - Deploy Time To Start the System:

    • Minimise Start-up dependencies & ordering • Invest in optimising the code executed during startup - Make it efficient!
  75. Slow Acceptance Stage - Deploy Time To Start the System:

    • Minimise Start-up dependencies & ordering • Invest in optimising the code executed during startup - Make it efficient! • Consider better modularisation - Independently deployable services
  76. Slow Acceptance Stage - Testing • There is a common

    cycle: • Teams start writing acceptance tests and run them all sequentially
  77. Slow Acceptance Stage - Testing • There is a common

    cycle: • Teams start writing acceptance tests and run them all sequentially • As number of Acceptance Tests increases the time they take to deliver feedback lengthens
  78. Slow Acceptance Stage - Testing • There is a common

    cycle: • Teams start writing acceptance tests and run them all sequentially • As number of Acceptance Tests increases the time they take to deliver feedback lengthens • Teams parallelise Acceptance Tests tactically
 Typically teams start by running half the tests on one machine and half on another.
  79. Slow Acceptance Stage - Testing • There is a common

    cycle: • Teams start writing acceptance tests and run them all sequentially • As number of Acceptance Tests increases the time they take to deliver feedback lengthens • Teams parallelise Acceptance Tests tactically
 Typically teams start by running half the tests on one machine and half on another. • Teams move to more strategic (automated) parallelisation strategy
  80. Slow Acceptance Stage - Testing • There is a common

    cycle: • Teams start writing acceptance tests and run them all sequentially • As number of Acceptance Tests increases the time they take to deliver feedback lengthens • Teams parallelise Acceptance Tests tactically
 Typically teams start by running half the tests on one machine and half on another. • Teams move to more strategic (automated) parallelisation strategy Treat Acceptance Test Isolation Seriously From Day One!
  81. Slow Acceptance Stage - Testing • Test Avoidance is a

    great idea, but difficult to do well • Acceptance Tests find things that you don’t expect • Be careful that you don’t spend too much time calculating which tests to avoid
  82. Scaling-Up Artifact Repository Deployment Pipeline Acceptance Commit Component Performance System

    Performance Staging Env. Deployment App. Production Env. Deployment App. Source Repository Manual Test Env. Deployment App.
  83. Scaling-Up Artifact Repository Deployment Pipeline Acceptance Commit Component Performance System

    Performance Staging Env. Deployment App. Production Env. Deployment App. Source Repository Manual Test Env. Deployment App. Deployment Pipeline Commit Manual Test Env. Deployment App. Artifact Repository Acceptance Acceptance Test Environment
  84. Scaling-Up Artifact Repository Deployment Pipeline Acceptance Commit Component Performance System

    Performance Staging Env. Deployment App. Production Env. Deployment App. Source Repository Manual Test Env. Deployment App. Deployment Pipeline Commit Manual Test Env. Deployment App. Artifact Repository Acceptance Acceptance Test Environment A A
  85. Scaling-Up Artifact Repository Deployment Pipeline Acceptance Commit Component Performance System

    Performance Staging Env. Deployment App. Production Env. Deployment App. Source Repository Manual Test Env. Deployment App. Deployment Pipeline Commit Manual Test Env. Deployment App. Artifact Repository Acceptance Acceptance Test Environment A A
  86. Scaling-Up Artifact Repository Deployment Pipeline Acceptance Commit Component Performance System

    Performance Staging Env. Deployment App. Production Env. Deployment App. Source Repository Manual Test Env. Deployment App. Deployment Pipeline Commit Manual Test Env. Deployment App. Artifact Repository Acceptance Acceptance Test Environment Test Host Test Host Test Host Test Host Test Host A A
  87. Scaling-Up Artifact Repository Deployment Pipeline Acceptance Commit Component Performance System

    Performance Staging Env. Deployment App. Production Env. Deployment App. Source Repository Manual Test Env. Deployment App. Deployment Pipeline Commit Manual Test Env. Deployment App. Artifact Repository Acceptance Acceptance Acceptance Test Environment Test Host Test Host Test Host Test Host Test Host A A
  88. Pipeline Problems • Slow Commit Stage • Slow Acceptance Stage

    • Failing Tests • Intermittent Tests • Pipeline Changes
  89. Pipeline Problems • Slow Commit Stage • Slow Acceptance Stage

    • Failing Tests • Intermittent Tests • Pipeline Changes
  90. Failing Tests • The Efficiency of the Feedback Cycle is

    central to the ability of a team to keep tests green!
  91. Artifact Repository Local Dev. Env. Deployment Pipeline Acceptance Commit Component

    Performance System Performance Production Env. Deployment Commit Acceptance Manual Perf1 Perf2 Staged Production Source Repository Manual Test Deployment Data Migration
  92. Artifact Repository Local Dev. Env. Deployment Pipeline Acceptance Commit Component

    Performance System Performance Production Env. Deployment Commit Acceptance Manual Perf1 Perf2 Staged Production Source Repository Manual Test Deployment Data Migration < 5 Minutes
  93. Artifact Repository Local Dev. Env. Deployment Pipeline Acceptance Commit Component

    Performance System Performance Production Env. Deployment Commit Acceptance Manual Perf1 Perf2 Staged Production Source Repository Manual Test Deployment Data Migration < 5 Minutes < 60 Minutes
  94. Failing Tests • Continuous Delivery is about: 
 Keeping the

    build in a releasable state Prioritise Fixing Failing Tests!
  95. Pipeline Problems • Slow Commit Stage • Slow Acceptance Stage

    • Failing Tests • Intermittent Tests • Pipeline Changes
  96. Pipeline Problems • Slow Commit Stage • Slow Acceptance Stage

    • Failing Tests • Intermittent Tests • Pipeline Changes
  97. Intermittent Tests Some CI systems even support running failing tests

    several times!! Why? • If the test passes once and fails once how do you know which result is correct?
  98. Intermittent Tests Common Causes: • Race Conditions • Poor Test

    Isolation • Poorly Designed Test Cases • Sometimes it is something serious!
  99. Intermittent Tests Common Causes: • Race Conditions • Poor Test

    Isolation • Poorly Designed Test Cases • Sometimes it is something serious! Prioritise Fixing Intermittent Tests!
  100. Pipeline Problems • Slow Commit Stage • Slow Acceptance Stage

    • Failing Tests • Intermittent Tests • Pipeline Changes
  101. Pipeline Problems • Slow Commit Stage • Slow Acceptance Stage

    • Failing Tests • Intermittent Tests • Pipeline Changes
  102. Pipeline Changes • The Deployment Pipeline is a Strategic Resource

    • Consider SLAs for your pipeline • Redundancy, Clustering, HLA?
  103. Make Your Pipeline the ONLY Route to Production Artefact Repository

    Local Dev. Env. Deployment Pipeline Acceptance Commit Component Performance System Performance Production Env. Deployment App. Commit Acceptance Manual Perf1 Perf2 Staged Production Source Repository Manual Test Env. Deployment App. Data Migration