Slide 1

Slide 1 text

Continuous Deployment Chris Keathley / @ChrisKeathley / [email protected]

Slide 2

Slide 2 text

I work with a distributed team

Slide 3

Slide 3 text

I work with a distributed team

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Warehouse

Slide 10

Slide 10 text

Warehouse API

Slide 11

Slide 11 text

Warehouse API Apps

Slide 12

Slide 12 text

The problem

Slide 13

Slide 13 text

Slow Iteration Cycle Deployment Deployment 2 weeks

Slide 14

Slide 14 text

Slow Iteration Cycle Deployment Deployment Deployment 2 weeks 2 weeks

Slide 15

Slide 15 text

Slow Iteration Cycle Deployment Deployment Deployment 3 weeks

Slide 16

Slide 16 text

Slow Iteration Cycle Deployment Deployment Deployment Hopefully someday

Slide 17

Slide 17 text

Large PRs

Slide 18

Slide 18 text

Unsure about state of the application

Slide 19

Slide 19 text

Unsure about state of the application

Slide 20

Slide 20 text

Unsure about state of the application

Slide 21

Slide 21 text

Unsure about state of the application

Slide 22

Slide 22 text

Unsure about state of the application

Slide 23

Slide 23 text

Rollbacks are a scam

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

Data Migration

Slide 27

Slide 27 text

Data Migration ?

Slide 28

Slide 28 text

Don’t do this

Slide 29

Slide 29 text

always Move forward

Slide 30

Slide 30 text

always Move forward

Slide 31

Slide 31 text

always Move forward

Slide 32

Slide 32 text

The goal should never be to roll back a deployment

Slide 33

Slide 33 text

The goal is to minimize the damage done by any given deployment

Slide 34

Slide 34 text

There are bugs in your system

Slide 35

Slide 35 text

Solutions

Slide 36

Slide 36 text

We needed to deploy more often

Slide 37

Slide 37 text

So we did

Slide 38

Slide 38 text

Automated Deployment

Slide 39

Slide 39 text

What do you deploy?

Slide 40

Slide 40 text

Commit Sha

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

Jars

Slide 43

Slide 43 text

Artifacts

Slide 44

Slide 44 text

Git Tags

Slide 45

Slide 45 text

Containers

Slide 46

Slide 46 text

Your App

Slide 47

Slide 47 text

Your App Server

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

Master Branch How we merge our code PR

Slide 50

Slide 50 text

CI Github Registry Container Slack PR Notification

Slide 51

Slide 51 text

CI Kubernetes Deploy Auto-deploy Green builds of master

Slide 52

Slide 52 text

CI Kubernetes Deploy Auto-deploy Green builds of master Service A Service B

Slide 53

Slide 53 text

CI Kubernetes Deploy Auto-deploy Green builds of master Service B

Slide 54

Slide 54 text

CI Kubernetes Deploy Auto-deploy Green builds of master Service B Service A

Slide 55

Slide 55 text

CI Kubernetes Deploy Auto-deploy Green builds of master Service A

Slide 56

Slide 56 text

CI Kubernetes Deploy Auto-deploy Green builds of master Service A Service B

Slide 57

Slide 57 text

Tests Metrics &

Slide 58

Slide 58 text

Integration Tests + Property Tests

Slide 59

Slide 59 text

Integration Tests TEst App DB Service

Slide 60

Slide 60 text

Modeling Users as FSMs logged_out logged_in login logout vote

Slide 61

Slide 61 text

Property Tests Add Todo Edit Todo Delete Todo

Slide 62

Slide 62 text

Property Tests Add Todo Edit Todo Delete Todo

Slide 63

Slide 63 text

Property Tests Add Todo Edit Todo Delete Todo

Slide 64

Slide 64 text

Property Tests Add Todo Edit Todo Delete Todo

Slide 65

Slide 65 text

Generate Commands

Slide 66

Slide 66 text

Generated Commands [{:add_todo, “Test Todo”, 1}, {:edit_todo, "Edited", 2}, {:delete_todo, "", 1}, {:add_todo, “New Todo", 3}, {:delete_todo, "", 2} {:edit_todo, “Edited Todo”, 2}]

Slide 67

Slide 67 text

Generate Commands

Slide 68

Slide 68 text

Generate Commands

Slide 69

Slide 69 text

Generate Commands

Slide 70

Slide 70 text

Generate Commands

Slide 71

Slide 71 text

Generate Commands

Slide 72

Slide 72 text

Generated Commands [{:add_todo, “Test Todo”, 1}, {:edit_todo, "Edited", 2}, {:delete_todo, "", 1}, {:add_todo, “New Todo", 3}, {:delete_todo, "", 2} {:edit_todo, “Edited Todo”, 2}]

Slide 73

Slide 73 text

Generated Commands [{:add_todo, “Test Todo”, 1}, {:delete_todo, "", 2}] [{:add_todo, “Test Todo”, 1}, {:edit_todo, "Edited", 2}, {:delete_todo, "", 1}, {:add_todo, “New Todo", 3}, {:delete_todo, "", 2} {:edit_todo, “Edited Todo”, 2}]

Slide 74

Slide 74 text

Prometheus Service A Grafana Service B Service C

Slide 75

Slide 75 text

Prometheus Service A Grafana Service B Service C Slack

Slide 76

Slide 76 text

# Alert for any instance that have a 95th percentile > 200ms. ALERT APIHighRequestLatency IF api_http_request_latencies_second{quantile="0.95"} > 0.2 FOR 5m ANNOTATIONS { summary = "High request latency on {{ $labels.instance }}", description = "{{ $labels.instance }} has a median request latency above 1s (current value: {{ $value }}s)", }

Slide 77

Slide 77 text

Track “Business” Metrics

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

Feature releases and flags

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

Features aren’t all or nothing

Slide 82

Slide 82 text

Features != Deployments

Slide 83

Slide 83 text

Deployment

Slide 84

Slide 84 text

Deployment Features

Slide 85

Slide 85 text

Deployment Features

Slide 86

Slide 86 text

User

Slide 87

Slide 87 text

User staff?(user) == true

Slide 88

Slide 88 text

User staff?(user) == false

Slide 89

Slide 89 text

User staff?(user) == false

Slide 90

Slide 90 text

defmodule MyApp.FeatureFlags do alias MyApp.User def foo_enabled?(%User{staff: is_staff}), do: is_staff def foo_enabled?(_), do: false def bar_enabled?(%User{staff: is_staff}), do: is_staff def bar_enabled?(_), do: false end

Slide 91

Slide 91 text

Browser Feature Service

Slide 92

Slide 92 text

Feature Service Feature Service Feature Service

Slide 93

Slide 93 text

Feature Service Feature Service Feature Service

Slide 94

Slide 94 text

Feature Service Feature Service Feature Service

Slide 95

Slide 95 text

You have updates ready! Reset

Slide 96

Slide 96 text

No content

Slide 97

Slide 97 text

With larger Traffic numbers you could use percentages

Slide 98

Slide 98 text

Alchemy

Slide 99

Slide 99 text

“Transmute lead code into gold in production”

Slide 100

Slide 100 text

Prior Art: https://github.com/github/scientist

Slide 101

Slide 101 text

Users_Controller DB User.all

Slide 102

Slide 102 text

DB User.all UserService.all

Slide 103

Slide 103 text

User.all UserService.all ==

Slide 104

Slide 104 text

def index(conn) do users = old_query() render(conn, "index.json", users: users) end

Slide 105

Slide 105 text

def index(conn) do users = experiment("users-query") |> control(&old_query/0) |> candidate(&new_query/0) |> run render(conn, "index.json", users: users) end

Slide 106

Slide 106 text

def index(conn) do users = experiment("users-query") |> control(&old_query/0) |> candidate(&new_query/0) |> candidate(&fancy_query/0) |> run render(conn, "index.json", users: users) end

Slide 107

Slide 107 text

1) Shuffles test order 2) Runs Each test in parallel 3) exports the data Alchemy

Slide 108

Slide 108 text

DB User.all UserService.all Control Candidate Control UserController

Slide 109

Slide 109 text

No content

Slide 110

Slide 110 text

1) Do the results match? 2) How long does each test take to return? Measure

Slide 111

Slide 111 text

No more cutovers

Slide 112

Slide 112 text

DB User.all UserService.all

Slide 113

Slide 113 text

DB User.all UserService.all User service

Slide 114

Slide 114 text

Migrations

Slide 115

Slide 115 text

http://blog.datomic.com/2017/01/the-ten-rules-of-schema-growth.html

Slide 116

Slide 116 text

DB Schema App Application Coupling

Slide 117

Slide 117 text

Your application knows about your schema

Slide 118

Slide 118 text

Lets remove a column

Slide 119

Slide 119 text

Lets remove a column 1) all application code needs to stop using that column

Slide 120

Slide 120 text

Lets remove a column 1) all application code needs to stop using that column 2) Update all ETL processes

Slide 121

Slide 121 text

Lets remove a column 1) all application code needs to stop using that column 2) Update all ETL processes 3) Update Reporting

Slide 122

Slide 122 text

Lets remove a column 1) all application code needs to stop using that column 2) Update all ETL processes 3) Update Reporting 4) Remove the column

Slide 123

Slide 123 text

Lets remove a column 1) all application code needs to stop using that column 2) Update all ETL processes 3) Update Reporting 4) Remove the column Split all of these up

Slide 124

Slide 124 text

Lets Add a column

Slide 125

Slide 125 text

Lets Add a column 1) Add the column

Slide 126

Slide 126 text

Lets Add a column 1) Add the column 2) Eventually start using it

Slide 127

Slide 127 text

Prefer Additive Migrations

Slide 128

Slide 128 text

CI Kubernetes Deploy Auto-deploy Green builds of master

Slide 129

Slide 129 text

CI Kubernetes Deploy Auto-deploy Green builds of master Migration

Slide 130

Slide 130 text

CI Kubernetes Deploy Auto-deploy Green builds of master Migration DB

Slide 131

Slide 131 text

Chat-Ops

Slide 132

Slide 132 text

No content

Slide 133

Slide 133 text

Chat is…

Slide 134

Slide 134 text

Chat is… Centralized

Slide 135

Slide 135 text

Chat is… Centralized Transparent

Slide 136

Slide 136 text

Chat is… Centralized Transparent Open

Slide 137

Slide 137 text

Try to do operational tasks in chat

Slide 138

Slide 138 text

No content

Slide 139

Slide 139 text

defmodule Hedwig.Responders.Ping do use Hedwig.Responder @usage """ hedwig: ping - Responds with 'pong' """ respond ~r/ping$/i, msg do reply msg, "pong" end end

Slide 140

Slide 140 text

No content

Slide 141

Slide 141 text

Generate grafana graphs

Slide 142

Slide 142 text

No content

Slide 143

Slide 143 text

Deploy

Slide 144

Slide 144 text

No content

Slide 145

Slide 145 text

Team Building

Slide 146

Slide 146 text

Conclusion

Slide 147

Slide 147 text

These are tools at our disposal

Slide 148

Slide 148 text

Deploy more often, safely

Slide 149

Slide 149 text

Thanks Chris Keathley / @ChrisKeathley / [email protected]