breaking down the monolith - peter marton, risingstack
TRANSCRIPT
![Page 1: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/1.jpg)
Breaking down the monolithPeter Marton, Trace by RisingStack
![Page 2: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/2.jpg)
whoamiwork: CTO, Co-founder of RisingStack
twitter: slashdotpeter
email: [email protected]
blog: https://blog.risingstack.com
![Page 3: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/3.jpg)
agenda1. Monolith and Microservices
2. Our experiences
3. Microservices challenges
![Page 4: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/4.jpg)
1. Monolith and microservices
![Page 5: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/5.jpg)
monolith
![Page 6: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/6.jpg)
monolithself-contained
![Page 7: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/7.jpg)
monolithresponsible for multiple tasks
![Page 8: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/8.jpg)
monolithindependent from other services
![Page 9: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/9.jpg)
microservice
https://microserviceweekly.com
![Page 10: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/10.jpg)
microservicesmaller services each with separate DB
https://microserviceweekly.com
![Page 11: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/11.jpg)
microservicesplit code by featurenot by functionality
https://microserviceweekly.com
![Page 12: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/12.jpg)
microservicecomplexity in network
https://microserviceweekly.com
![Page 13: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/13.jpg)
microserviceNOT FOR MVP!
![Page 14: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/14.jpg)
agenda1. Monolith and Microservices
2. Our experiences
3. Microservices challenges
![Page 15: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/15.jpg)
What is Trace?- I work on it
- Product by RisingStack
- Node.js and microservice monitoring tool
- Built with Node.js
- Built as a monolith in MVP phase
![Page 16: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/16.jpg)
![Page 17: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/17.jpg)
Why we moved to microservices?
![Page 18: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/18.jpg)
Why we moved?
growing engineering team
![Page 19: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/19.jpg)
Why we moved?
separated features -> focused people
![Page 20: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/20.jpg)
Why we moved?
need for fault tolerance
![Page 21: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/21.jpg)
2. Our experiences
![Page 22: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/22.jpg)
Pros
![Page 23: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/23.jpg)
Well focused independent teams (pro)
![Page 24: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/24.jpg)
Easier to scale a specific part (pro)
![Page 25: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/25.jpg)
Easier to develop a feature (pro)
![Page 26: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/26.jpg)
Features fails independently (pro)
![Page 27: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/27.jpg)
Cons
![Page 28: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/28.jpg)
Increasing architectural complexity (cons)
![Page 29: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/29.jpg)
Increasingresponse times (cons)
![Page 30: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/30.jpg)
Harder totest and deploy (cons)
![Page 31: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/31.jpg)
agenda1. Monolith and Microservices
2. Our experiences
3. Microservices challenges
![Page 32: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/32.jpg)
3. Microservice challenges
![Page 33: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/33.jpg)
Fault tolerance
![Page 34: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/34.jpg)
If monitoring goes down...who knows that you are down?
![Page 35: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/35.jpg)
Fault tolerance
servicesfail separately
![Page 36: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/36.jpg)
Fault tolerance
critical resources should be cached
![Page 37: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/37.jpg)
Our service caching- service level caching
- our service-lib handles it
- via cache headers
![Page 38: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/38.jpg)
Fault tolerance
temporary failures -> persistent queues
![Page 39: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/39.jpg)
Fault tolerance
event sourcing(not just microservices)
![Page 40: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/40.jpg)
~Event sourcing with queue
![Page 41: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/41.jpg)
Increasing complexity
![Page 42: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/42.jpg)
Where we started (~8 months ago)
![Page 43: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/43.jpg)
Where we are (today)
![Page 44: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/44.jpg)
What if it breaks?
![Page 45: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/45.jpg)
Logs everywhere
![Page 46: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/46.jpg)
Where is the issue?
![Page 47: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/47.jpg)
there...
![Page 48: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/48.jpg)
Distributed tracing- Trace by RisingStack
- Zipkin
- Google Dapper white paper
- Transaction ID, Correlation ID
![Page 49: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/49.jpg)
Response time
![Page 50: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/50.jpg)
Even with very fast services
![Page 51: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/51.jpg)
...you can have a slow app
:(
![Page 52: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/52.jpg)
Because of network delays
![Page 53: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/53.jpg)
Network delay is evil in microservices
![Page 54: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/54.jpg)
Keep your services “close” to each other
![Page 55: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/55.jpg)
Proxy approach
![Page 56: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/56.jpg)
Proxy
![Page 57: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/57.jpg)
Proxy- Re-route requests to services
- Authorize requests via access-service
- Decorate flippers (feature flag)
- Rewrite urls
![Page 58: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/58.jpg)
Proxy- Evolutionary design (pro)
- Authentication in proxy (pro)
- Cookie handling at service (cons)
- Service format response for browser (cons)
![Page 59: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/59.jpg)
Services interfaces are designed with browser in mind
![Page 60: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/60.jpg)
API Gateway
![Page 61: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/61.jpg)
API Gateway
Img: http://bits.citrusbyte.com/microservices
![Page 62: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/62.jpg)
API Gateway- Everything that’s client(s) specific:
- Auth: Cookie headers, JWT token etc.
- Response format: JSON, XML etc.
- Combine resources: from multiple services
![Page 63: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/63.jpg)
Security
![Page 64: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/64.jpg)
Request signing- Trusted sources (services) on public channel
- node-http-signature
- Built-in in request and super-request npm
modules
https://github.com/joyent/node-http-signature
![Page 65: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/65.jpg)
Request signing
![Page 66: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/66.jpg)
Service teams
![Page 67: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/67.jpg)
Your services are productsfor your customers and co-workers!
![Page 68: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/68.jpg)
Service principles
![Page 69: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/69.jpg)
Service principles
max. three depth call chains
![Page 70: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/70.jpg)
Service principles
always backward compatible endpoints
![Page 71: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/71.jpg)
Service principles
do not version services (only endpoints)
![Page 72: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/72.jpg)
Service principles
use feature toggles heavily (flippers)
![Page 73: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/73.jpg)
Service principles
good to start here:https://github.com/Yelp/service-principles
![Page 74: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/74.jpg)
Documented API(s)
![Page 75: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/75.jpg)
Documented API
enforce documentation
![Page 76: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/76.jpg)
Documented API
update docstogether with code
![Page 77: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/77.jpg)
Documented API
make it availablefor everyone
![Page 78: Breaking Down the Monolith - Peter Marton, RisingStack](https://reader034.vdocuments.net/reader034/viewer/2022042722/58a84f9c1a28ab210b8b597d/html5/thumbnails/78.jpg)
Thanks!
https://trace.risingstack.com