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

Breaking Down The Monolith - NodeConfBP

Breaking Down The Monolith - NodeConfBP

RisingStack's journey about breaking down a monolith application into microservices.
Presented at https://nodeconf.risingstack.com in 2017 January.

Contact speaker here: https://twitter.com/slashdotpeter

Included topics:

- Business and technology benefits and drawbacks of microservices
- Why we moved
- Service principles: versioning and documenting
- Automation
- Proxy and API Gateway approaches
- Fault tolerance: Caching, CQRS
- Request Signing
- Zero downtime deployment: Kubernetes, Graceful shutdown, Rolling deployment, Self-healing
- Microservices monitoring and debugging challenges
- Distributed Tracing
- Network Delay use-case

What's next?

https://blog.risingstack.com/tag/node-js-at-scale
https://www.martinfowler.com/microservices
https://microserviceweekly.com/
https://trace.risingstack.com

Peter Marton

January 20, 2017
Tweet

More Decks by Peter Marton

Other Decks in Programming

Transcript

  1. Breaking Down The Monolith

    View Slide

  2. - CTO, Co-founder of RisingStack
    - @slashdotpeter on Twitter
    - https://blog.risingstack.com
    $ whoami

    View Slide

  3. Microservices
    Img: http://ryanjbaxter.com

    View Slide

  4. Moving to microservices

    View Slide

  5. Moving to microservices

    View Slide

  6. - Co-located teams can work more efficiently
    - different space / time zone
    - Smaller teams are usually more efficient
    - More focused people
    - Faster onboarding for new developers
    Possible business reasons to move

    View Slide

  7. - Improved fault isolation
    - Independent development
    - Independent deployment
    - Allows technology diversity
    Technology benefits

    View Slide

  8. - Increasing architectural complexity
    - Increasing operational complexity
    - Monitoring and debugging are much harder
    - Handling eventual Consistency
    Technology drawbacks

    View Slide

  9. microservice architecture is
    not a silver bullet

    View Slide

  10. Why we moved?

    View Slide

  11. - Microservice monitoring tool
    - Node.js focused
    - Built in Node.js
    - We migrated to microservices architecture
    Trace by RisingStack

    View Slide

  12. - We wanted to have more focused teams
    - We have very different challenges
    - Fault tolerance is a key in our business
    Why we moved?

    View Slide

  13. Before we moved

    View Slide

  14. Today

    View Slide

  15. How we moved?

    View Slide

  16. Services and teams

    View Slide

  17. - Separate DB per service
    - Maximize the depth of service call chains
    Service principles

    View Slide

  18. - We create backward compatible endpoints
    - We don’t version services (only endpoints)
    - Use feature flippers/toggles (dark launches)
    Service principles

    View Slide

  19. - Good and available documentation
    - Update docs and code together
    Good to start here: https://github.com/Yelp/service-principles
    Service principles

    View Slide

  20. Automation

    View Slide

  21. - Automation is a key in building and operating microservices
    - Easy and fast to deploy
    - Easy and fast to rollback
    - Testing, Service bootstrap, DB migration etc.
    Automation

    View Slide

  22. Proxy / API Gateway

    View Slide

  23. Proxy / API Gateway

    View Slide

  24. - Client(s) specific things:
    - Authentication: Cookie headers, JWT token etc.
    - Protocols: http, WebSocket etc.
    - Response format: JSON, XML etc.
    - Combining resources: from multiple services
    API Gateway

    View Slide

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

    View Slide

  26. Fault tolerance

    View Slide

  27. - Services fail separately (in theory)
    - Critical resources should be cached
    - Messaging queues can help (HTTP request is not recoverable)
    Fault tolerance

    View Slide

  28. Fault tolerant data collection - CQRS
    read
    write

    View Slide

  29. Fault tolerant data collecting
    Queue size increasing during issue
    Queue size decreasing after issue resolved

    View Slide

  30. Caching

    View Slide

  31. - On service level
    - Automatically via response headers
    - Via our communication package
    - Multi store caching (in memory, Redis):
    https://www.npmjs.com/package/cache-manager
    Caching

    View Slide

  32. Security

    View Slide

  33. - Trusted sources (services) on public channel
    - Request signing between services
    - Significant CPU overhead
    Request signing

    View Slide

  34. Request signing

    View Slide

  35. Infrastructure

    View Slide

  36. - Started with PaaS
    - We moved to Kubernetes
    - Zero downtime deployment
    Infrastructure

    View Slide

  37. Zero downtime deployment
    Deploy

    View Slide

  38. - Graceful shutdown
    - Rolling deployment
    - Self healing applications
    - Horizontal autoscaling
    Infrastructure

    View Slide

  39. Monitoring and debugging

    View Slide

  40. Microservices producing lot’s of data
    - Logs, Errors
    - Metrics per service
    - Transactions
    - Logical connections
    - Side effects

    View Slide

  41. microservice monitoring is
    impossible for humans

    View Slide

  42. How to find an issue?
    Alerting, Dashboard
    Topology
    Metrics, Errors
    Traces
    Profiler
    Investigate a service
    Locate on code level
    Understand connections
    Identify participating services
    Always know about it

    View Slide

  43. Distributed tracing

    View Slide

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

    View Slide

  45. Case study: Network delay

    View Slide

  46. Case study: Network delay
    3.8ms 564.8ms
    95th response time:
    Call depth: 1 service 2 services

    View Slide

  47. Case study: Network delay
    network delay

    View Slide

  48. network delay is evil
    in microservices

    View Slide

  49. - https://blog.risingstack.com/tag/node-js-at-scale
    - https://www.martinfowler.com/microservices
    - https://microserviceweekly.com/
    - https://trace.risingstack.com
    What’s next?

    View Slide

  50. Thanks!

    View Slide

  51. View Slide