Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Nodepb - Breaking Down the Monolith

Nodepb - Breaking Down the Monolith

How we broke down our monolith and what we learned from it.

http://www.meetup.com/nodebp/events/229220584/

Peter Marton

March 30, 2016
Tweet

More Decks by Peter Marton

Other Decks in Programming

Transcript

  1. Breaking Down the Monolith
    Péter Márton
    @slashdotpeter

    View full-size slide

  2. whoami
    - work: CTO, Co-founder of RisingStack, Inc.
    - twitter: slashdotpeter
    - email: [email protected]
    - blog: https://blog.risingstack.com

    View full-size slide

  3. Agenda
    - Monolith and Microservices
    - Advantages of Microservices
    - Disadvantages of Microservices
    - How we did

    View full-size slide

  4. Monolith
    - Self-contained
    - Responsible for multiple task
    - Independent from other services

    View full-size slide

  5. Microservice
    - Smaller services with separate DB
    - Split code by feature not by functionality
    - Feature teams (cross-functional)
    - More focused teams with distributed responsibility
    - Not for MVP!
    https://microserviceweekly.com/

    View full-size slide

  6. What is ?
    - Our product (RisingStack)
    - Microservice monitoring tool
    - With distributed stack traces
    - Built with Node.js
    - Built as a monolith in MVP phase

    View full-size slide

  7. Why we moved?

    View full-size slide

  8. Microservices at RisingStack
    - Growing engineering team
    - Fault tolerance
    - Well focused service teams
    - Easier to scale
    - Well separated features

    View full-size slide

  9. Fault tolerance

    View full-size slide

  10. If Trace goes down...
    who knows that you are down?

    View full-size slide

  11. Fault tolerance
    - Separated services
    - Single point of failure should be cached
    - Event sourcing

    View full-size slide

  12. ~Event sourcing

    View full-size slide

  13. Where we started

    View full-size slide

  14. Where we are

    View full-size slide

  15. What if it breaks?

    View full-size slide

  16. Lot’s of logs

    View full-size slide

  17. Where is the issue?

    View full-size slide

  18. Response time

    View full-size slide

  19. Even with very fast services

    View full-size slide

  20. ...you can have a slow app
    :(

    View full-size slide

  21. Because of network delays

    View full-size slide

  22. That’s why we are leaving PaaS
    - AWS Elastic Beanstalk
    - VPC -> internal routing
    - Docker
    - Etcd with confd
    - $$$ efficient?

    View full-size slide

  23. 600 ms -> 200 ms

    View full-size slide

  24. Network delay is evil
    in microservices

    View full-size slide

  25. “Smart” proxy

    View full-size slide

  26. Proxy
    - Route requests to services
    - Authorize requests via access-service
    - Decorate flippers (feature flag)
    - Rewrite urls
    - Evolutionary design
    - Everything is stateless REST between services

    View full-size slide

  27. Request signing

    View full-size slide

  28. Request signing
    - Trusted sources (services) on public channel
    - https://github.com/joyent/node-http-signature
    - Built-in in request and super-request npm modules
    POST /foo HTTP/1.1
    Host: example.org
    Date: Tue, 07 Jun 2014 20:51:35 GMT
    Content-Type: application/json
    Digest: SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
    Content-Length: 18

    View full-size slide

  29. Service teams

    View full-size slide

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

    View full-size slide

  31. Service principles

    View full-size slide

  32. Service principles
    - max 3 depth call chains
    - always backward compatible endpoints
    - Do not version services, only endpoints
    - use flippers heavily
    - https://github.com/Yelp/service-principles
    - In progress...

    View full-size slide

  33. Documented API
    - Enforce documentation
    - Create service mocks from docs
    - Auto update docs from GitHub repository
    - Make it available for everyone

    View full-size slide

  34. Documented API - apiary

    View full-size slide

  35. Project management

    View full-size slide

  36. Changes
    - Multiple teams
    - Cross dependencies
    - Sprints

    View full-size slide

  37. Thanks!
    trace.risingstack.com

    View full-size slide