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

No content

Slide 6

Slide 6 text

monolith everything in one process

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

npm's monolith: embedded in couchdb

Slide 9

Slide 9 text

monoliths work just fine

Slide 10

Slide 10 text

whatever it takes to build a system that satisfies your users

Slide 11

Slide 11 text

success! now scale it.

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

scaling monoliths many copies of the full thing

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

exponential monoliths were going to be expensive

Slide 17

Slide 17 text

splitting the monolith

Slide 18

Slide 18 text

yay microservices?

Slide 19

Slide 19 text

just rewrite everything! what's the problem?

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

what did that Gall guy say about complex working systems?

Slide 22

Slide 22 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 23

Slide 23 text

Systemantics: How Systems Really Work and How They Fail

Slide 24

Slide 24 text

"A simple system may or may not work."

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

Gall's Law warns us about that rewrite

Slide 27

Slide 27 text

how do you split a monolith successfully?

Slide 28

Slide 28 text

Let's cheat.

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

then write a second implementation of that interface

Slide 32

Slide 32 text

send requests to that second implementation with a proxy

Slide 33

Slide 33 text

No content

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

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

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

first step just send everything through

Slide 41

Slide 41 text

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

Slide 42

Slide 42 text

second step divide & conquer

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

beat Gall's Law with modularity aka information hiding

Slide 46

Slide 46 text

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

Slide 47

Slide 47 text

best part: now you can change everything

Slide 48

Slide 48 text

your platform your database

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

why stop there?

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

the awesome

Slide 55

Slide 55 text

Each piece is a simple system

Slide 56

Slide 56 text

more scaling dials to turn finer-grained perf data

Slide 57

Slide 57 text

isolating tasks let us debug even without splitting the monolith

Slide 58

Slide 58 text

the system overall is complex but loosely coupled

Slide 59

Slide 59 text

you have a working system every step of the way

Slide 60

Slide 60 text

a proxy service lets you flip back & forth between implementations

Slide 61

Slide 61 text

the pitfalls

Slide 62

Slide 62 text

now you've got a distributed system

Slide 63

Slide 63 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 64

Slide 64 text

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

Slide 65

Slide 65 text

Generalize only when forced

Slide 66

Slide 66 text

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

Slide 67

Slide 67 text

simple working service first scale it later

Slide 68

Slide 68 text

respect Gall: rewrite in pieces

Slide 69

Slide 69 text

use a proxy to divide & conquer

Slide 70

Slide 70 text

Be bold you can change your system

Slide 71

Slide 71 text

Nobody noticed when we changed the entire npm registry

Slide 72

Slide 72 text

npm loves you npm install -g npm@latest