ARCHITECTING FOR CONTINUOUS DELIVERY Ken Mugrage ThoughtWorks - - PowerPoint PPT Presentation

architecting for continuous delivery
SMART_READER_LITE
LIVE PREVIEW

ARCHITECTING FOR CONTINUOUS DELIVERY Ken Mugrage ThoughtWorks - - PowerPoint PPT Presentation

ARCHITECTING FOR CONTINUOUS DELIVERY Ken Mugrage ThoughtWorks Technology Advocate @kmugrage https://gocd.org/ TEAM STRUCTURE @kmugrage https://gocd.org/ CONWAYS LAW Any organization that designs a system (defined broadly) will produce


slide-1
SLIDE 1

@kmugrage https://gocd.org/

ARCHITECTING FOR CONTINUOUS DELIVERY

Ken Mugrage – ThoughtWorks Technology Advocate

slide-2
SLIDE 2

@kmugrage https://gocd.org/

TEAM STRUCTURE

slide-3
SLIDE 3

@kmugrage https://gocd.org/

CONWAY’S LAW

Any organization that designs a system (defined broadly) will produce a design whose structure is a copy of the organization's communication structure.

slide-4
SLIDE 4

@kmugrage https://gocd.org/

YOU BUILD IT, YOU RUN IT

“…It also brings them into day-to-day contact with the customer. This customer feedback loop is essential for improving the quality of the service.”

slide-5
SLIDE 5

@kmugrage https://gocd.org/

CODE MANAGEMENT

slide-6
SLIDE 6

@kmugrage https://gocd.org/

TRUNK BASED DEVELOPMENT

https://martinfowler.com/bliki/FeatureBranch.html

slide-7
SLIDE 7

@kmugrage https://gocd.org/

TRUNK BASED DEVELOPMENT

https://martinfowler.com/bliki/FeatureBranch.html

slide-8
SLIDE 8

@kmugrage https://gocd.org/

TRUNK BASED DEVELOPMENT

https://martinfowler.com/bliki/FeatureBranch.html

slide-9
SLIDE 9

@kmugrage https://gocd.org/

The purpose of a Continuous Delivery pipeline is to kill release candidates

slide-10
SLIDE 10

@kmugrage https://gocd.org/

FEATURE TOGGLES

function reticulateSplines(){ // current implementation lives here }

https://martinfowler.com/articles/feature-toggles.html by Pete Hodgson

slide-11
SLIDE 11

@kmugrage https://gocd.org/

FEATURE TOGGLES

function reticulateSplines(){ var useNewAlgorithm = false; // useNewAlgorithm = true; // UNCOMMENT IF YOU ARE WORKING ON THE NEW SR ALGORITHM if( useNewAlgorithm ){ return enhancedSplineReticulation(); } else { return oldFashionedSplineReticulation(); } } function oldFashionedSplineReticulation(){ // current implementation lives here } function enhancedSplineReticulation(){ // TODO: implement better SR algorithm }

https://martinfowler.com/articles/feature-toggles.html by Pete Hodgson

slide-12
SLIDE 12

@kmugrage https://gocd.org/

FEATURE TOGGLES

https://martinfowler.com/articles/feature-toggles.html by Pete Hodgson

slide-13
SLIDE 13

@kmugrage https://gocd.org/

THE PIPELINE

Build Functional Tests Regression Tests Deploy To Stage Deploy To Production Build Toggles Off Toggles On Deploy To Stage Deploy To Production

slide-14
SLIDE 14

@kmugrage https://gocd.org/

BRANCH BY ABSTRACTION

Client Code Client Code Client Code Old Supplier https://martinfowler.com/bliki/BranchByAbstraction.html

slide-15
SLIDE 15

@kmugrage https://gocd.org/

BRANCH BY ABSTRACTION

Client Code Client Code Client Code Old Supplier Abstraction Layer https://martinfowler.com/bliki/BranchByAbstraction.html

slide-16
SLIDE 16

@kmugrage https://gocd.org/

BRANCH BY ABSTRACTION

Client Code Client Code Client Code Old Supplier Abstraction Layer https://martinfowler.com/bliki/BranchByAbstraction.html

slide-17
SLIDE 17

@kmugrage https://gocd.org/

BRANCH BY ABSTRACTION

Client Code Client Code Client Code Old Supplier Abstraction Layer https://martinfowler.com/bliki/BranchByAbstraction.html New Supplier Abstraction Layer

slide-18
SLIDE 18

@kmugrage https://gocd.org/

BRANCH BY ABSTRACTION

Client Code Client Code Client Code New Supplier Abstraction Layer https://martinfowler.com/bliki/BranchByAbstraction.html

slide-19
SLIDE 19

@kmugrage https://gocd.org/

ARCHITECTURE

slide-20
SLIDE 20

@kmugrage https://gocd.org/

WELL VERSIONED APIS

/api/users/v1

  • ID
  • Name
  • Email

Consumer 1 Consumer 2 Consumer 3

slide-21
SLIDE 21

@kmugrage https://gocd.org/

WELL VERSIONED APIS

/api/users/v1

  • ID
  • Name
  • Email

/api/users/v2

  • ID
  • FirstName
  • LastName
  • Email

Consumer 1 Consumer 2 Consumer 3

slide-22
SLIDE 22

@kmugrage https://gocd.org/

WELL VERSIONED APIS

/api/users/v1

  • ID
  • Name
  • Email

/api/users/v2

  • ID
  • FirstName
  • LastName
  • Email

Consumer 1 Consumer 2 Consumer 3

slide-23
SLIDE 23

@kmugrage https://gocd.org/

WELL VERSIONED APIS

/api/users/v2

  • ID
  • FirstName
  • LastName
  • Email

Consumer 1 Consumer 2 Consumer 3

slide-24
SLIDE 24

@kmugrage https://gocd.org/

NO SHARED DATA STORE

Service One Service Two DB

slide-25
SLIDE 25

@kmugrage https://gocd.org/

NO SHARED DATA STORE

Service One Service Two DB DB

slide-26
SLIDE 26

@kmugrage https://gocd.org/

EVENT DRIVEN APPLICATIONS

slide-27
SLIDE 27

@kmugrage https://gocd.org/

WITHOUT EVENTS

https://martinfowler.com/articles/201701-event-driven.html User Service Quote Service Quote Service Quote Service Quote Service

slide-28
SLIDE 28

@kmugrage https://gocd.org/

EVENT NOTIFICATION

User Service Quote Service Service Service Service https://martinfowler.com/articles/201701-event-driven.html

slide-29
SLIDE 29

@kmugrage https://gocd.org/

EVENT SOURCING

  • You don’t write to the data store, you create an event which writes to

the store

  • The test: You could completely blow away the store and recreate it

from the event stream

  • You use this model every day (I hope)

https://martinfowler.com/articles/201701-event-driven.html

slide-30
SLIDE 30

@kmugrage https://gocd.org/

TESTING DISTRIBUTED APPS

  • We’re using external services
  • We can’t reliably test them
  • Flaky tests are worse than no tests
slide-31
SLIDE 31

@kmugrage https://gocd.org/

TEST DOUBLES

On Every Continuous Integration Run

Client Code Test Double

slide-32
SLIDE 32

@kmugrage https://gocd.org/

CONTRACT TESTING

On Every Continuous Integration Run

Client Code Test Double

Occasionally

Contract Test Their Test Service

slide-33
SLIDE 33

@kmugrage https://gocd.org/

CONSUMER DRIVEN CONTRACTS

  • Provider runs tests which verify they won’t break consumers
  • Shifts responsibility to the provider
  • Acts as a communication method

https://www.thoughtworks.com/radar/techniques/consumer-driven-contract-testing

slide-34
SLIDE 34

@kmugrage https://gocd.org/

TESTING WEB APPS

  • Adding waits to tests makes them non-deterministic (flaky)
  • Non-deterministic tests are bad
slide-35
SLIDE 35

@kmugrage https://gocd.org/

TESTING WEB APPS

  • Test specifications in markdown
  • Multiple language support
  • Maintainable tests
  • GPL v3.0
  • Reliable browser automation
  • Request/Response stubbing and

mocking

  • Smart Selectors
  • MIT License

https://gauge.org/ https://taiko.gauge.org/

slide-36
SLIDE 36

@kmugrage https://gocd.org/

OBSERVABILITY

In control theory, observability is a measure of how well internal states

  • f a system can be inferred from knowledge of its external outputs. The
  • bservability and controllability of a system are mathematical duals.

The concept of observability was introduced by Hungarian-American engineer Rudolf E. Kálmán for linear dynamic systems.

slide-37
SLIDE 37

@kmugrage https://gocd.org/

DOMAIN ORIENTED OBSERVABILITY

applyDiscountCode(discountCode){ this.instrumentation.applyingDiscountCode(discountCode); let discount; try { discount = this.discountService.lookupDiscount(discountCode); } catch (error) { this.instrumentation.discountCodeLookupFailed(discountCode,error); return 0; } this.instrumentation.discountCodeLookupSucceeded(discountCode); const amountDiscounted = discount.applyToCart(this); this.instrumention.discountApplied(discount,amountDiscounted); return amountDiscounted; }

https://martinfowler.com/articles/domain-oriented-observability.html by Pete Hodgson

slide-38
SLIDE 38

@kmugrage https://gocd.org/

O U R A C T U A L P I P E L I N E

slide-39
SLIDE 39

@kmugrage https://gocd.org/

DEPLOYMENT

slide-40
SLIDE 40

@kmugrage https://gocd.org/

EXPA N D / CON T RAC T FOR DATA BA S ES

DB Version 1

  • ID (not null)
  • Name (not null)
  • Email (not null)

DB Version 2

  • ID (not null)
  • Name (not null)
  • FirstName
  • LastName
  • Email (not null)

App Version 1 App Version 1 DB Version 2

  • ID (not null)
  • Name (not null)
  • FirstName
  • LastName
  • Email (not null)

App Version 2

slide-41
SLIDE 41

@kmugrage https://gocd.org/

EXPA N D / CON T RAC T FOR DATA BA S ES

DB Version 2

  • ID (not null)
  • Name (not null)
  • FirstName
  • LastName
  • Email (not null)

App Version 2 select FirstName, LastName from users If null select Name from users Prompt user to update Update FirstName, LastName select FirstName, LastName from users

slide-42
SLIDE 42

@kmugrage https://gocd.org/

CANARY RELEASE

slide-43
SLIDE 43

@kmugrage https://gocd.org/

CANARY RELEASE

Release to a very small portion of our audience to “test in production”. ( Pro Tip: Test for business efficacy not just successful bits and bytes )

slide-44
SLIDE 44

@kmugrage https://gocd.org/

CANARY RELEASE

Release to a very small portion of our audience to “test in production”. ( Pro Tip: Test for business efficacy not just successful bits and bytes )

slide-45
SLIDE 45

@kmugrage https://gocd.org/

CANARY RELEASE

Release to a very small portion of our audience to “test in production”. ( Pro Tip: Test for business efficacy not just successful bits and bytes )

slide-46
SLIDE 46

@kmugrage https://gocd.org/

SUMMARY

  • Small, well versioned pieces are best
  • Small, well focused teams are best to create those
  • Continuous Integration is the foundation
slide-47
SLIDE 47

@kmugrage https://gocd.org/

THANK YOU