Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

Breaking down the monolith Peter Marton, Trace by RisingStack

Slide 3

Slide 3 text

whoami company: CTO, Co-founder of RisingStack work: Trace By RisingStack twitter: slashdotpeter blog: https://blog.risingstack.com

Slide 4

Slide 4 text

What is ? - Node.js performance monitoring tool - Microservice debugging tool - Built with Node.js - Built as a monolith in MVP phase

Slide 5

Slide 5 text

agenda 1. Monolith and Microservices 2. Why we moved to microservices? 3. Our experiences with microservices 4. Microservices challenges

Slide 6

Slide 6 text

1. Monolith and microservices

Slide 7

Slide 7 text

monolith

Slide 8

Slide 8 text

monolith self-contained

Slide 9

Slide 9 text

monolith responsible for multiple tasks

Slide 10

Slide 10 text

microservice https://microserviceweekly.com

Slide 11

Slide 11 text

microservice smaller services each with separate DB https://microserviceweekly.com

Slide 12

Slide 12 text

microservice split code by feature not by functionality https://microserviceweekly.com

Slide 13

Slide 13 text

microservice complexity in network https://microserviceweekly.com

Slide 14

Slide 14 text

microservice NOT FOR MVP!

Slide 15

Slide 15 text

agenda 1. Monolith and Microservices 2. Why we moved to microservices? 3. Our experiences with microservices 4. Microservices challenges

Slide 16

Slide 16 text

2. Why we moved to microservices?

Slide 17

Slide 17 text

Why microservices? growing engineering team

Slide 18

Slide 18 text

Why microservices? separated features -> more focused people

Slide 19

Slide 19 text

Why microservices? need for fault tolerance

Slide 20

Slide 20 text

agenda 1. Monolith and Microservices 2. Why we moved to microservices? 3. Our experiences with microservices 4. Microservices challenges

Slide 21

Slide 21 text

3. Our experiences with microservices

Slide 22

Slide 22 text

Pros

Slide 23

Slide 23 text

Well focused independent teams (pro)

Slide 24

Slide 24 text

Faster innovation (pro)

Slide 25

Slide 25 text

Easier to scale a specific part (pro)

Slide 26

Slide 26 text

Features fail independently (pro)

Slide 27

Slide 27 text

Cons

Slide 28

Slide 28 text

Increasing architectural complexity (cons)

Slide 29

Slide 29 text

Increasing response times (cons)

Slide 30

Slide 30 text

Harder to test (cons)

Slide 31

Slide 31 text

Microservice experiences - Independent and focused teams (pro) - Faster innovation (pro) - Easier to scale (pro) - Features fail independently (pro) - Increasing architectural complexity (cons) - Increasing response times (cons) - Harder to test (cons)

Slide 32

Slide 32 text

agenda 1. Monolith and Microservices 2. Why we moved to microservices? 3. Our experiences with microservices 4. Microservices challenges

Slide 33

Slide 33 text

4. Microservice challenges

Slide 34

Slide 34 text

Fault tolerance

Slide 35

Slide 35 text

If monitoring goes down... who knows that you are down?

Slide 36

Slide 36 text

Fault tolerance services fail separately

Slide 37

Slide 37 text

Fault tolerance critical resources should be cached

Slide 38

Slide 38 text

Our caching - service level caching - our service-lib handles it - via cache headers - Not an SDK

Slide 39

Slide 39 text

Fault tolerance temporary failures -> CQRS, reliable queue

Slide 40

Slide 40 text

~CQRS

Slide 41

Slide 41 text

Persistent queue

Slide 42

Slide 42 text

Increasing complexity

Slide 43

Slide 43 text

Where we started (~8 months ago)

Slide 44

Slide 44 text

Where we are (today)

Slide 45

Slide 45 text

What if it breaks?

Slide 46

Slide 46 text

Logs everywhere

Slide 47

Slide 47 text

Distributed tracing

Slide 48

Slide 48 text

Distributed tracing

Slide 49

Slide 49 text

Distributed tracing - Transaction ID, Correlation ID - Google Dapper white paper - Trace by RisingStack (SaaS) - Zipkin

Slide 50

Slide 50 text

Response time

Slide 51

Slide 51 text

Even with very fast services

Slide 52

Slide 52 text

...you can have a slow app :(

Slide 53

Slide 53 text

Because of network delays

Slide 54

Slide 54 text

Network delay is evil in microservices

Slide 55

Slide 55 text

Keep your services “close” to each other

Slide 56

Slide 56 text

Proxy approach

Slide 57

Slide 57 text

Proxy

Slide 58

Slide 58 text

Proxy - Evolutionary design (pro) - Authentication in proxy (pro) - Cookie handling at service (cons) - Service formats response for browser (cons)

Slide 59

Slide 59 text

Services interfaces are designed with browser in mind

Slide 60

Slide 60 text

API Gateway

Slide 61

Slide 61 text

API Gateway Img: http://bits.citrusbyte.com/microservices

Slide 62

Slide 62 text

API Gateway - Everything that’s client(s) specific: - Auth: Cookie headers, JWT token etc. - Protocol: http, WebSocket etc. - Response format: JSON, XML etc. - Combine resources: from multiple services

Slide 63

Slide 63 text

Security

Slide 64

Slide 64 text

Request signing - Trusted sources (services) on public channel - node-http-signature - Built-in in request and super-request npm libs https://github.com/joyent/node-http-signature

Slide 65

Slide 65 text

Service teams

Slide 66

Slide 66 text

Your services are products for your customers and co-workers!

Slide 67

Slide 67 text

Service principles

Slide 68

Slide 68 text

Service principles max. three depth call chains

Slide 69

Slide 69 text

Service principles always backward compatible endpoints

Slide 70

Slide 70 text

Service principles do not version services (only endpoints)

Slide 71

Slide 71 text

Service principles use feature toggles heavily (flippers)

Slide 72

Slide 72 text

Service principles good to start here: https://github.com/Yelp/service-principles

Slide 73

Slide 73 text

Documented API(s)

Slide 74

Slide 74 text

Documented API enforce documentation

Slide 75

Slide 75 text

Documented API update docs together with code

Slide 76

Slide 76 text

Documented API make it available for everyone

Slide 77

Slide 77 text

Challenges - Fault tolerance - Debugging with distributed tracing - Response times - Proxy / API Gateway - Service teams and principles - Documented API(s)

Slide 78

Slide 78 text

Thanks! https://trace.risingstack.com