The Road to Continuous Deployment

45

Transcript of The Road to Continuous Deployment

Page 1: The Road to Continuous Deployment
Page 2: The Road to Continuous Deployment

THE ROAD TO CONTINUOUS DEPLOYMENT - A CASE STUDY

MICHIEL ROOK

@michieltcs

Page 3: The Road to Continuous Deployment
Page 4: The Road to Continuous Deployment

THE SYSTEM - SAN DIEGO

▸ ... or the Big Ball Of Mud

▸ Large legacy monolith

▸ Generates significant income

▸ Slow & complex

▸ Technical debt

@michieltcs

Page 5: The Road to Continuous Deployment

SAN DIEGO FRONTEND

MYSQL DB

SAN DIEGO BACKEND

LOAD BALANCERS / VARNISH

ITBANEN INTERMEDIAIR NATIONALEVACATUREBANK

SAN DIEGO FRONTEND

SAN DIEGO FRONTEND

SAN DIEGO FRONTEND

SAN DIEGO BACKEND

SAN DIEGO BACKEND

SAN DIEGO BACKEND

MEMCACHE FTP EXT. SERVICES

SOLR

@michieltcs

Page 6: The Road to Continuous Deployment

THE SYSTEM - SAN DIEGO

▸ Infrequent, manual releases

▸ Fragile tests

▸ Frequent outages & issues

▸ Frustrated team

▸ Low confidence modifying existing code

@michieltcs

Page 7: The Road to Continuous Deployment

GOALS

▸ Reduce issues

▸ Reduce cycle time

▸ Increase productivity

▸ Increase motivation

Page 8: The Road to Continuous Deployment

REFACTOR? REBUILD?

Page 9: The Road to Continuous Deployment

APPROACH

▸ Strangler pattern

▸ API first

▸ Services per domain object (job, jobseeker, ...)

▸ Migrate individual pages

@michieltcs

Page 10: The Road to Continuous Deployment

ORIGINAL MONOLITH

PROXY

SERVICEORIGINAL MONOLITH

ORIGINAL MONOLITH

SERVICE SERVICE

SERVICE

PROXY

DB

DBDB

DB

DB DB

@michieltcs

Page 11: The Road to Continuous Deployment

APPROACH

▸ Services behind load balancers

▸ Access legacy db’s

▸ Continuous deployment

▸ Docker containers

▸ Frontends are services

@michieltcs

Page 12: The Road to Continuous Deployment

CONTINUOUS EVERYTHING

Page 13: The Road to Continuous Deployment

DEV BUILD / TEST

CONTINUOUS INTEGRATION

@michieltcs

Page 14: The Road to Continuous Deployment

DEV BUILD / TEST ACCEPTANCE PRODUCTION

CONTINUOUS DELIVERY

@michieltcs

Page 15: The Road to Continuous Deployment

DEV BUILD / TEST STAGING PRODUCTION

CONTINUOUS DEPLOYMENT

@michieltcs

Page 16: The Road to Continuous Deployment

WHY CONTINUOUS DEPLOYMENT

▸ Small steps

▸ Early feedback

▸ Reduce cycle time

▸ Reduce risk

▸ Experiments!

@michieltcs

Page 17: The Road to Continuous Deployment

SUCCESSFUL TEAMS HAVE

@michieltcs

Page 18: The Road to Continuous Deployment

ONLY COMMIT TO MASTER

Page 19: The Road to Continuous Deployment

EVERY COMMIT GOES TO PRODUCTION

Page 20: The Road to Continuous Deployment

PAIR PROGRAMMING

Page 21: The Road to Continuous Deployment

QUALITY GATES

Page 22: The Road to Continuous Deployment

FEATURE TOGGLES, A/B TESTS

@michieltcs

Page 23: The Road to Continuous Deployment

DASHBOARDS

Page 24: The Road to Continuous Deployment

DEVOPS

Page 25: The Road to Continuous Deployment

AUTOMATE REPEATABLE THINGS

Page 26: The Road to Continuous Deployment

CONTINUOUS TESTING

Page 27: The Road to Continuous Deployment

CONTINUOUS TESTING

UNIT TESTS

INTEGRATION TESTS

ACCEPTANCE TESTS

UI TESTS

SMOKETESTS

Cost Speed

Exploratorytesting Monitoring

@michieltcs

Page 28: The Road to Continuous Deployment

PIPELINE AS CODE

node { stage 'Run tests' sh "phpunit" sh "behat" stage 'Build docker image' sh "phing build" sh "docker build -t jobservice:${env.BUILD_NUMBER} ." sh "docker push jobservice:${env.BUILD_NUMBER}" stage 'Deploy acceptance' sh "ansible-playbook -e BUILD=${env.BUILD_NUMBER} -i acc deploy.yml" stage 'Deploy production' sh "ansible-playbook -e BUILD=${env.BUILD_NUMBER} -i prod deploy.yml" }

@michieltcs

Page 29: The Road to Continuous Deployment

DEPLOYING

PULL IMAGE

START NEW CONTAINER

WAIT FOR PORT

SMOKE TESTS / HEALTH CHECKS

ADD NEW CONTAINER TO LB

REMOVE OLD CONTAINER FROM LB

STOP OLD CONTAINER

docker pull

@michieltcs

Page 30: The Road to Continuous Deployment

DEPLOYING

PULL IMAGE

START NEW CONTAINER

WAIT FOR PORT

SMOKE TESTS / HEALTH CHECKS

ADD NEW CONTAINER TO LB

REMOVE OLD CONTAINER FROM LB

STOP OLD CONTAINER

docker run

@michieltcs

Page 31: The Road to Continuous Deployment

DEPLOYING

PULL IMAGE

START NEW CONTAINER

WAIT FOR PORT

SMOKE TESTS / HEALTH CHECKS

ADD NEW CONTAINER TO LB

REMOVE OLD CONTAINER FROM LB

STOP OLD CONTAINER

wait_for: port=8080 delay=5 timeout=15

@michieltcs

Page 32: The Road to Continuous Deployment

DEPLOYING

PULL IMAGE

START NEW CONTAINER

WAIT FOR PORT

SMOKE TESTS / HEALTH CHECKS

ADD NEW CONTAINER TO LB

REMOVE OLD CONTAINER FROM LB

STOP OLD CONTAINER

uri: url: http://localhost:8080/_health status_code: 200 timeout: 30

@michieltcs

Page 33: The Road to Continuous Deployment

DEPLOYING

PULL IMAGE

START NEW CONTAINER

WAIT FOR PORT

SMOKE TESTS / HEALTH CHECKS

ADD NEW CONTAINER TO LB

REMOVE OLD CONTAINER FROM LB

STOP OLD CONTAINER

template: src=haproxy.cfg.j2 dest=/etc/haproxy/haproxy.cfg

service: name=haproxy state=reloaded

@michieltcs

Page 34: The Road to Continuous Deployment

DEPLOYING

PULL IMAGE

START NEW CONTAINER

WAIT FOR PORT

SMOKE TESTS / HEALTH CHECKS

ADD NEW CONTAINER TO LB

REMOVE OLD CONTAINER FROM LB

STOP OLD CONTAINER

template: src=haproxy.cfg.j2 dest=/etc/haproxy/haproxy.cfg

service: name=haproxy state=reloaded

@michieltcs

Page 35: The Road to Continuous Deployment

DEPLOYING

PULL IMAGE

START NEW CONTAINER

WAIT FOR PORT

SMOKE TESTS / HEALTH CHECKS

ADD NEW CONTAINER TO LB

REMOVE OLD CONTAINER FROM LB

STOP OLD CONTAINER

docker stop

docker rm

@michieltcs

Page 36: The Road to Continuous Deployment

BUILD PIPELINE

@michieltcs

Page 37: The Road to Continuous Deployment

FEEDBACK!

Page 38: The Road to Continuous Deployment

RESULTS

Page 39: The Road to Continuous Deployment

RESULTS

▸ Total build time per service < 10 minutes

▸ Significantly improved page load times

▸ Improved audience stats (time on page, pages per session, session duration, traffic, seo ranking, etc)

▸ Increased confidence and velocity

▸ Experimented with new tech/stacks (angular, jvm, event sourcing)

▸ More fun

@michieltcs

Page 40: The Road to Continuous Deployment

LESSONS LEARNED

▸ Team acceptance

▸ Change is hard

▸ Mentality / discipline

▸ Docker stability/orchestration

▸ Issues with traffic between Amazon <-> on-premise datacenter

@michieltcs

Page 41: The Road to Continuous Deployment

LESSONS LEARNED

▸ Experience with new tech

▸ Stability of build pipelines

▸ Business alignment

▸ Limit feature toggles

▸ Keep focus on replacing legacy application

@michieltcs

Page 42: The Road to Continuous Deployment
Page 43: The Road to Continuous Deployment
Page 44: The Road to Continuous Deployment

Turn-key Continuous Deployment

Zero downtime deployments

Modern, autoscaling infrastructure with built-in monitoring

Pipeline in five minutes

Page 45: The Road to Continuous Deployment

THANK YOU!

@michieltcs / [email protected]

Turn-key Continuous Deployment