Slide 1

Slide 1 text

Cheating Gall's Law

Slide 2

Slide 2 text

C J Silverio director of engineering, @ceejbot

Slide 3

Slide 3 text

Cheating Gall's Law How we split a monolith and lived to tell the tale

Slide 4

Slide 4 text

Gall's Law A complex system that works is invariably found to have evolved from a simple system that worked.

Slide 5

Slide 5 text

Gall's Law in full “A complex system that works is invariably found to have evolved from a simple system that worked. A complex system designed from scratch never works and cannot be patched up to make it work. You have to start over with a working simple system.”

Slide 6

Slide 6 text

"A simple system may or may not work."

Slide 7

Slide 7 text

Systemantics: How Systems Really Work and How They Fail

Slide 8

Slide 8 text

starting simple often means starting with a monolith

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

monolith everything in one process

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

npm's monolith: embedded in couchdb

Slide 13

Slide 13 text

monoliths work just fine

Slide 14

Slide 14 text

whatever it takes to build a system that satisfies your users

Slide 15

Slide 15 text

success! now scale it.

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

scaling monoliths many copies of the full thing

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

Exponential growth of node resulted in exponential growth of the npm registry

Slide 20

Slide 20 text

exponential monoliths were going to be expensive

Slide 21

Slide 21 text

splitting the monolith

Slide 22

Slide 22 text

yay microservices?

Slide 23

Slide 23 text

just rewrite everything! what's the problem?

Slide 24

Slide 24 text

Your monolith is complex. A split system is more complex.

Slide 25

Slide 25 text

what did that Gall guy say about complex working systems?

Slide 26

Slide 26 text

"If a system is working, leave it alone. Don't change anything."

Slide 27

Slide 27 text

Gall's Law warns us about that rewrite

Slide 28

Slide 28 text

how do you split a monolith successfully?

Slide 29

Slide 29 text

Let's cheat.

Slide 30

Slide 30 text

Q: How do you cheat? A: By not rewriting the whole thing.

Slide 31

Slide 31 text

slice off a part of the system into a module with a clearly-defined interface

Slide 32

Slide 32 text

then write a second implementation of that interface

Slide 33

Slide 33 text

send requests to that second implementation with a proxy

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

now let's make our proxy smart Replace Varnish with a node service

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

first step just send everything through

Slide 42

Slide 42 text

record what the proxy does how do people use your service? measure performance

Slide 43

Slide 43 text

second step divide & conquer

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

beat Gall's Law with modularity aka information hiding

Slide 47

Slide 47 text

each service is a module a simple, testable system when viewed in isolation

Slide 48

Slide 48 text

best part: now you can change everything

Slide 49

Slide 49 text

your platform your database

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

why stop there?

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

the awesome

Slide 56

Slide 56 text

Each piece is a simple system

Slide 57

Slide 57 text

more scaling dials to turn finer-grained perf data

Slide 58

Slide 58 text

isolating tasks let us debug even without splitting the monolith

Slide 59

Slide 59 text

the system overall is complex but loosely coupled

Slide 60

Slide 60 text

you have a working system every step of the way

Slide 61

Slide 61 text

a proxy service lets you flip back & forth between implementations

Slide 62

Slide 62 text

the not awesome

Slide 63

Slide 63 text

now you've got a distributed system

Slide 64

Slide 64 text

@architectclippy says “I see you have a poorly structured monolith. Would you like me to convert it into a poorly structured set of microservices?”

Slide 65

Slide 65 text

Second system syndrome "this time we'll do it right"

Slide 66

Slide 66 text

Generalize only when forced

Slide 67

Slide 67 text

let's recap! how do you survive a rewrite?

Slide 68

Slide 68 text

simple working service first scale it later

Slide 69

Slide 69 text

respect Gall: rewrite in pieces

Slide 70

Slide 70 text

use a proxy to divide & conquer

Slide 71

Slide 71 text

Be bold you can change your system

Slide 72

Slide 72 text

Nobody noticed when we changed the entire npm registry

Slide 73

Slide 73 text

loves you npm install -g npm@latest