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

Handing Failure in Microservice Architectures

mattheath
January 15, 2016

Handing Failure in Microservice Architectures

Presented at NDC London on 15th January 2016

Microservice architectures allow us to decompose domain logic into small services with a bounded context, which allows us to gain simplicity within services at the expense of complexity in the interactions between services.

However any distributed system operating at scale will experience failure, and this interaction complexity makes dealing with failure harder. This is especially important when requests may traverse many systems, and failures of a single component may cascade through several more. In this talk we look at a number of common patterns from simple usage of concurrency primitives and timeouts to control and throttle concurrency, to more complex patterns such as the CircuitBreaker which can be used to prevent cascading failures; increasing the reliability of our systems.

mattheath

January 15, 2016
Tweet

More Decks by mattheath

Other Decks in Programming

Transcript

  1. Handling Failure in
    Microservice Architectures
    Matt Heath, Mondo
    #ndclondon

    View full-size slide

  2. monoliths
    traditional dev

    View full-size slide

  3. DATABASE
    APPLICATION

    View full-size slide

  4. DATABASE
    APPLICATION

    View full-size slide

  5. DATABASE
    DATABASES
    APPLICATION

    View full-size slide

  6. DATABASE
    DATABASES
    APPLICATION
    SEARCH

    View full-size slide

  7. DATABASE
    DATABASES
    APPLICATION
    CACHE
    SEARCH

    View full-size slide

  8. DATABASE
    DATABASES
    APPLICATION
    CACHE
    SEARCH
    CAT GIFS

    View full-size slide

  9. ALL
    HAIL
    THE
    MONOLITH

    View full-size slide

  10. DATABASE
    DATABASES
    APPLICATION
    CACHE
    SEARCH
    CAT GIFS

    View full-size slide

  11. Are your systems
    reliable?

    View full-size slide

  12. 2012 June - RBS - Batch processing causes 3 day outage
    2013 December - RBS - Card payments, cash withdrawals
    2015 June - RBS lose 600,000 payments
    2015 August - HSBC lose 275,000 payments
    2015 October - Barclays - Failure of accounts and cards
    2016 January - HSBC - 2 day outage of online systems

    View full-size slide

  13. Graceful handling
    of failure is essential

    View full-size slide

  14. Do microservices
    make this worse?

    View full-size slide

  15. The Fallacies of
    Distributed Computing

    View full-size slide

  16. Everything
    can and will fail

    View full-size slide

  17. Identifying
    Failure

    View full-size slide

  18. LOAD BALANCER
    HTTP API & ROUTING LAYER

    View full-size slide

  19. API
    SERVICE
    LOAD BALANCER
    HTTP API & ROUTING LAYER

    View full-size slide

  20. /webhooks —-> Webhook API

    View full-size slide

  21. WEBHOOK
    API
    LOAD BALANCER
    HTTP API & ROUTING LAYER

    View full-size slide

  22. WEBHOOK
    API
    AUTH
    SERVICE
    WEBHOOK
    SERVICE
    LOAD BALANCER
    HTTP API & ROUTING LAYER

    View full-size slide

  23. WEBHOOK
    API
    AUTH
    SERVICE
    WEBHOOK
    SERVICE
    LOAD BALANCER
    HTTP API & ROUTING LAYER

    View full-size slide

  24. WEBHOOK
    API
    AUTH
    SERVICE
    WEBHOOK
    SERVICE
    LOAD BALANCER
    HTTP API & ROUTING LAYER

    View full-size slide

  25. WEBHOOK
    API
    AUTH
    SERVICE
    WEBHOOK
    SERVICE
    LOAD BALANCER
    HTTP API & ROUTING LAYER

    View full-size slide

  26. Error Tracking
    and Propagation

    View full-size slide

  27. api webhook api webhook service
    api webhook api webhook service

    View full-size slide

  28. api webhook api webhook service
    api webhook api webhook service

    View full-size slide

  29. api webhook api webhook service
    api webhook api webhook service
    error

    View full-size slide

  30. api webhook api webhook service
    api webhook api webhook service
    error
    SENTRY

    View full-size slide

  31. api webhook api webhook service
    api webhook api webhook service
    error
    SENTRY

    View full-size slide

  32. api webhook api webhook service
    api webhook api webhook service
    error
    SENTRY
    error
    partition

    View full-size slide

  33. api webhook api webhook service
    api webhook api webhook service
    ?????
    SENTRY
    error

    View full-size slide

  34. api webhook api webhook service
    api webhook api webhook service
    ?????
    SENTRY
    error
    timeout

    View full-size slide

  35. api webhook api webhook service
    api webhook api webhook service
    ?????
    SENTRY
    error
    timeout
    error
    timeout

    View full-size slide

  36. api webhook api webhook service
    api webhook api webhook service
    ?????
    SENTRY
    error
    error
    error
    error
    duplicated errors

    View full-size slide

  37. api webhook api webhook service
    api webhook api webhook service
    ?????
    SENTRY
    error
    error
    error
    error

    View full-size slide

  38. 8096820c-3b7b-47ec-bce6-1c239252ab40

    View full-size slide

  39. api webhook api webhook service
    api webhook api webhook service
    ?????
    SENTRY
    error
    error
    error
    error

    View full-size slide

  40. api webhook api webhook service
    api webhook api webhook service
    ?????
    SENTRY
    error
    error
    error
    error

    View full-size slide

  41. api webhook api webhook service
    api webhook api webhook service
    ?????
    SENTRY
    error
    error
    error
    error

    View full-size slide

  42. api webhook api webhook service
    api webhook api webhook service
    ?????
    SENTRY
    error
    error
    error
    error
    hash & deduplicate

    View full-size slide

  43. Service
    Healthchecks

    View full-size slide

  44. type Checker func() (error, map[string]string)

    View full-size slide

  45. Endpoint error %
    DB Connection Status
    Configuration loaded?

    View full-size slide

  46. Instrumentation

    View full-size slide

  47. metrics.Counter(1.0, "cassandra.read.error", 1)

    View full-size slide

  48. metrics.Timing(1.0, "cassandra.read", time.Since(start))

    View full-size slide

  49. STATSD
    SERVICE A UDP
    SERVICE B UDP
    HOST INSTANCES
    GRAFANA
    INFLUXDB
    METRICS

    View full-size slide

  50. TELEGRAF
    w/
    STATSD

    PLUGIN
    SERVICE A UDP
    SERVICE B UDP
    HOST INSTANCES
    GRAFANA
    INFLUXDB
    TAGGED METRICS

    View full-size slide

  51. Handling

    Failure

    View full-size slide

  52. Timing out
    and moving on

    View full-size slide

  53. Sensible
    Timeouts?

    View full-size slide

  54. Measure
    EVERYTHING!

    View full-size slide

  55. api webhook api webhook service
    api webhook api webhook service

    View full-size slide

  56. api webhook api webhook service
    api webhook api webhook service
    Client
    Logic
    Server

    View full-size slide

  57. api webhook api webhook service
    api webhook api webhook service
    Client
    Logic
    Server

    View full-size slide

  58. Client
    Remote Server
    Circuit Breaker

    View full-size slide

  59. Client
    Remote Server
    Circuit Breaker
    Error! Error!

    View full-size slide

  60. Client
    Remote Server
    Circuit Breaker
    Timeout! Timeout!

    View full-size slide

  61. Client
    Remote Server
    Circuit Breaker
    Circuit
    Open!
    OPEN

    View full-size slide

  62. Client
    Remote Server
    Circuit Breaker
    Return
    Error
    or
    Cached
    Results
    OPEN

    View full-size slide

  63. Topology
    Management

    View full-size slide

  64. WEBHOOK
    API
    LOAD BALANCER
    HTTP API & ROUTING LAYER
    WEBHOOK
    SERVICE
    WEBHOOK
    SERVICE
    WEBHOOK
    SERVICE

    View full-size slide

  65. WEBHOOK
    API
    LOAD BALANCER
    HTTP API & ROUTING LAYER
    WEBHOOK
    SERVICE
    WEBHOOK
    SERVICE
    WEBHOOK
    SERVICE

    View full-size slide

  66. WEBHOOK
    API
    LOAD BALANCER
    HTTP API & ROUTING LAYER
    WEBHOOK
    SERVICE
    WEBHOOK
    SERVICE
    WEBHOOK
    SERVICE
    WEBHOOK
    SERVICE

    View full-size slide

  67. WEBHOOK
    API
    LOAD BALANCER
    HTTP API & ROUTING LAYER
    WEBHOOK
    SERVICE
    WEBHOOK
    SERVICE
    WEBHOOK
    SERVICE
    WEBHOOK
    SERVICE
    SLOW /
    ERRORS

    View full-size slide

  68. Fanout &
    Cancellation

    View full-size slide

  69. WEBHOOK
    API
    WEBHOOK
    SERVICE
    WEBHOOK
    SERVICE
    WEBHOOK
    SERVICE

    View full-size slide

  70. WEBHOOK
    API
    WEBHOOK
    SERVICE
    WEBHOOK
    SERVICE
    WEBHOOK
    SERVICE

    View full-size slide

  71. WEBHOOK
    API
    WEBHOOK
    SERVICE
    WEBHOOK
    SERVICE
    WEBHOOK
    SERVICE

    View full-size slide

  72. WEBHOOK
    API
    WEBHOOK
    SERVICE
    WEBHOOK
    SERVICE
    WEBHOOK
    SERVICE

    View full-size slide

  73. WEBHOOK
    API
    WEBHOOK
    SERVICE
    WEBHOOK
    SERVICE
    WEBHOOK
    SERVICE

    View full-size slide

  74. Event Driven
    Architectures

    View full-size slide

  75. API
    SERVICE
    SERVICE
    A
    SERVICE
    B
    LOAD BALANCER
    HTTP API & ROUTING LAYER

    View full-size slide

  76. API
    SERVICE
    SERVICE
    A
    SERVICE
    B
    LOAD BALANCER
    HTTP API & ROUTING LAYER

    View full-size slide

  77. API
    SERVICE
    SERVICE
    A
    SERVICE
    B
    LOAD BALANCER
    HTTP API & ROUTING LAYER
    SERVICE
    C
    SERVICE
    D
    E

    View full-size slide

  78. API
    SERVICE
    SERVICE
    A
    SERVICE
    B
    LOAD BALANCER
    HTTP API & ROUTING LAYER
    SERVICE
    C
    SERVICE
    D
    G
    E
    F

    View full-size slide

  79. Retry Strategies

    View full-size slide

  80. Bounded exponential
    backoff

    View full-size slide

  81. Bounded exponential
    backoff with Jitter

    View full-size slide

  82. Encouraging
    Failure?

    View full-size slide

  83. Antifragility

    View full-size slide

  84. Chaos
    Engineering

    View full-size slide

  85. Load
    Failure
    Degradation

    View full-size slide

  86. Eliminate primaries
    and special nodes

    View full-size slide

  87. Putting it
    all together

    View full-size slide

  88. API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns
    API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns

    View full-size slide

  89. API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns
    API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns

    View full-size slide

  90. API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns
    API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns

    View full-size slide

  91. API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns
    API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns

    View full-size slide

  92. API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns
    API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns

    View full-size slide

  93. API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns
    API card-api card-processing cards transactions balance transaction-enrichment merchant feed-generator feed apns

    View full-size slide

  94. #ndclondon
    Thanks!
    @mattheath
    @getmondo

    View full-size slide

  95. ATM: Thomas Hawk

    Bank of Commerce: ABQ Museum Archives
    IBM System/360: IBM
    Absorbed: Saxbald Photography
    Orbital Ion Cannon: www.rom.ac
    Credits

    View full-size slide