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

Breaking Down the Monolith - Peter Marton, RisingStack

Peter Marton
September 15, 2016

Breaking Down the Monolith - Peter Marton, RisingStack

The story of how we broke our Node.js monolith into 15+ services in just a couple of weeks. The talk will focus on what we have learnt during the journey and what technologies we use. This is the tale of how we did this rather than what microservices are in general.

Peter Marton

September 15, 2016
Tweet

More Decks by Peter Marton

Other Decks in Technology

Transcript

  1. Breaking down the monolith
    Peter Marton, Trace by RisingStack

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  5. 1. Monolith and
    microservices

    View full-size slide

  6. monolith
    self-contained

    View full-size slide

  7. monolith
    responsible for
    multiple tasks

    View full-size slide

  8. microservice
    https://microserviceweekly.com

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  11. microservice
    complexity in
    network
    https://microserviceweekly.com

    View full-size slide

  12. microservice
    NOT FOR MVP!

    View full-size slide

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

    View full-size slide

  14. 2. Why we moved to
    microservices?

    View full-size slide

  15. Why microservices?
    growing engineering
    team

    View full-size slide

  16. Why microservices?
    separated features ->
    more focused people

    View full-size slide

  17. Why microservices?
    need for
    fault tolerance

    View full-size slide

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

    View full-size slide

  19. 3. Our experiences with
    microservices

    View full-size slide

  20. Well focused
    independent teams (pro)

    View full-size slide

  21. Faster innovation (pro)

    View full-size slide

  22. Easier to scale a
    specific part (pro)

    View full-size slide

  23. Features fail
    independently (pro)

    View full-size slide

  24. Increasing architectural
    complexity (cons)

    View full-size slide

  25. Increasing
    response times (cons)

    View full-size slide

  26. Harder to test (cons)

    View full-size slide

  27. 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)

    View full-size slide

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

    View full-size slide

  29. 4. Microservice
    challenges

    View full-size slide

  30. Fault tolerance

    View full-size slide

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

    View full-size slide

  32. Fault tolerance
    services
    fail separately

    View full-size slide

  33. Fault tolerance
    critical resources
    should be cached

    View full-size slide

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

    View full-size slide

  35. Fault tolerance
    temporary failures ->
    CQRS, reliable queue

    View full-size slide

  36. Persistent queue

    View full-size slide

  37. Increasing complexity

    View full-size slide

  38. Where we started (~8 months ago)

    View full-size slide

  39. Where we are (today)

    View full-size slide

  40. What if it breaks?

    View full-size slide

  41. Logs everywhere

    View full-size slide

  42. Distributed tracing

    View full-size slide

  43. Distributed tracing

    View full-size slide

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

    View full-size slide

  45. Response time

    View full-size slide

  46. Even with very fast services

    View full-size slide

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

    View full-size slide

  48. Because of network delays

    View full-size slide

  49. Network delay is evil
    in microservices

    View full-size slide

  50. Keep your services
    “close” to each other

    View full-size slide

  51. Proxy approach

    View full-size slide

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

    View full-size slide

  53. Services interfaces are
    designed with browser in mind

    View full-size slide

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

    View full-size slide

  55. 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

    View full-size slide

  56. 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

    View full-size slide

  57. Service teams

    View full-size slide

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

    View full-size slide

  59. Service principles

    View full-size slide

  60. Service principles
    max. three depth
    call chains

    View full-size slide

  61. Service principles
    always backward
    compatible endpoints

    View full-size slide

  62. Service principles
    do not version
    services (only endpoints)

    View full-size slide

  63. Service principles
    use feature toggles
    heavily (flippers)

    View full-size slide

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

    View full-size slide

  65. Documented API(s)

    View full-size slide

  66. Documented API
    enforce
    documentation

    View full-size slide

  67. Documented API
    update docs
    together with code

    View full-size slide

  68. Documented API
    make it available
    for everyone

    View full-size slide

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

    View full-size slide

  70. Thanks!
    https://trace.risingstack.com

    View full-size slide