37
The Anatomy of Continuous Deployment At Scale John Viner (Dev Manager) Mario Visic (Lead Developer of Delivery Engineering) 100 Deploys a Week at Envato

The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Embed Size (px)

Citation preview

Page 1: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

The Anatomy of Continuous Deployment

At Scale

John Viner (Dev Manager)Mario Visic (Lead Developer of Delivery Engineering)

100 Deploys a Week at Envato

Page 2: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Who is Envato?

Page 3: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

A two-sided Marketplace for creative assets that has paid out $400 million to our

“Authors” in the last 10 years

7 Sites where digital professionals can buy web templates, video, audio, code, graphics and 3d

models 7 million registered users10 million items for sale

Page 4: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Themeforest.net

Page 5: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Show me the Tech Stack

Ruby on Rails (100K loc, 25 web servers)

MySql (175 tables)

Memcached + RedisRackspace / VMWare

Amazon AWS

Page 6: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Show me the Numbers!

Peak of 25,000 requests p/min through Rails160m Page Views per Month

500,000 Database calls p/min Serving 200TB of data a month

22,000 Unit Tests, 2,000 Integration Tests

Page 7: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

How do we deliver change?

Page 8: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

By the numbers … for the month of June 2016

~ 40 developers3000 total builds (2.5 builds p/dev/day)

500 Pull Requests Closed400 deployments (18 p/day avg, 0.5 p/dev/day, peak 25)

4.5 hour cycle time (from first commit to deploy - working hours)

Page 9: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Statistics over Time

Size of a Pull Request (median)37 lines changed3 files changed

Cycle Time of a PR (first commit to deploy)average: 10.8 hours (working hours)median: 2.6 hours (working hours)

Deployments8400 deployments in 2 years

Page 10: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Pretty Charts - Builds

Page 11: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Deployments

Page 12: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Pull Requests

Page 13: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

PR Cycle Time (First Commit to Deployment)

Page 14: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Building Envato Market

Page 15: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Feature request

• 2 week sprints• Work with product team to break down work• No task larger than two days• Feature toggle can be used to push incomplete features

Page 16: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Feature request

Page 17: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Implementation

• Write the tests (sometimes first)• Write the code• Peer review• Get it into production

Page 18: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Implementation

Tests live alongside code, stored in Github

Page 19: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Implementation

Github Pull Request are the unit of change, 2 thumbs up by reviewers means the code is good to ship to production

Page 20: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Implementation

Page 21: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Implementation

Buildkite is our CI tool, a merge on master automatically runs a build. A successful build automatically triggers a production

deploy

Page 22: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Deployment

• Entirely Automated• Post deploy monitoring• Quick rollback• Multiple time per hour

Page 23: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Deployment

Samson (open source) is our deployment tool, successful master builds triggers a deploy which is logged in Samson.

Page 24: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Deployment

We can run manual deployments from Samson and view all PRs in a given deployment.

Page 25: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Deployment

We can trace back to specific changes in a deploy.

Page 26: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Deployment

… including the amount of lines changed. A typical PR changes only 37 lines of code across 3 files

Page 27: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Deployment

Page 28: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Why do we do this?

Page 29: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Lowers Risk

Size of Change is Small means …Easier to identify any failureEasier to rollback any failure

Reduces human errors due to reliance on automationSecurity patches can be deployed within minutes

Page 30: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

And also

Reduces Waste:Fewer handovers from Development to QA to Ops

Increases Product Agility:New features go to customers sooner to get earlier feedback

Increases developer ownership and engagement:More direct connection between your creation and it being used

Page 31: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

How to get there

Page 32: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Start with Culture

Foster an Ownership Culture in Developers

http://webuild.envato.com/expectations/collaboration/4-i-take-responsibility-for-syste.html

Page 33: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Investment in automation of unit tests, functional tests

Tests to cover legacy systems

Add Tests whenever un-tested code is touched

Set Targets and Measure Test Coverage and # Tests

Page 34: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Automate Deployments and Enable Feature Toggles

Automate your manual run sheet one line at a time

Start with Push Button

Feature Toggles help deploy features without showing them

Page 35: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Start Small

Use a less risky or complicated system first

Page 36: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Investment in monitoring and rollback

Knowing that the system is working within seconds becomes critical

Developers need to be “on the pager”

Invest in the ability to Roll Back

Optimise for Mean Time to Recover

Page 37: The Anatomy of Continuous Deployment at Scale - 100 deploys a week at Envato 2016

Thank you!