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

Building reliable APIs

Building reliable APIs

mattheath

July 10, 2018
Tweet

More Decks by mattheath

Other Decks in Programming

Transcript

  1. Building Reliable APIs
    Matt Heath, Monzo

    View full-size slide

  2. Matt Heath, Monzo
    @mattheath

    View full-size slide

  3. monoliths
    traditional dev

    View full-size slide

  4. What do we mean
    by “reliable”?

    View full-size slide

  5. Contacting us
    Using your debit card
    Making payments
    Freezing your card 

    Viewing your balance
    Viewing recent transactions
    Sending emoji reactions
    Setting your profile picture
    Viewing merchant logos

    View full-size slide

  6. Contacting us
    Using your debit card
    Making payments
    Freezing your card 

    Viewing your balance
    Viewing recent transactions
    Sending emoji reactions
    Setting your profile picture
    Viewing merchant logos

    View full-size slide

  7. APPLICATION
    Application

    View full-size slide

  8. API Gateway
    API
    Service
    API
    Service
    API
    Service
    API
    Service
    API
    Service
    API
    Service
    API
    Service
    API
    Service

    View full-size slide

  9. API Gateway
    Accounts Cards Pots Emojis Payments …

    View full-size slide

  10. API Gateway
    Accounts Cards Pots Emojis Payments …
    New

    Exciting

    API!!

    View full-size slide

  11. Cards Pots Emojis Payments …
    API Gateway
    Accounts
    New

    Exciting

    API!!





    View full-size slide

  12. Cards Pots Emojis Payments …
    API Gateway
    Accounts
    New

    Exciting

    API!!






    View full-size slide

  13. API Gateway
    Accounts Cards Pots Emojis Payments …
    New

    Exciting

    API!!


    View full-size slide

  14. pod
    container
    container
    container

    View full-size slide

  15. pod
    API service

    View full-size slide

  16. pods
    replica set

    View full-size slide

  17. replica set
    pods
    deployment

    View full-size slide

  18. pods
    replica set
    deployment

    View full-size slide

  19. pods
    replica set
    deployment
    change

    View full-size slide

  20. deployment
    change
    old pods
    old replica set

    View full-size slide

  21. deployment
    change
    old pods
    old replica set new replica set

    View full-size slide

  22. deployment
    change
    old pods
    old replica set new replica set
    new pod

    View full-size slide

  23. deployment
    change
    old pods
    old replica set new replica set
    new pod

    View full-size slide

  24. deployment
    change
    old replica set
    new pods
    new replica set

    View full-size slide

  25. deployment
    change
    new replica set
    new pods

    View full-size slide

  26. deployment
    replica set
    pods

    View full-size slide

  27. pods
    service
    kubedns

    View full-size slide

  28. pods
    service routing - static cluster IP
    managed replicas
    resource allocations
    rollout strategies
    liveness checks
    anti-affinity, etc
    kubedns routing - “service name”

    View full-size slide

  29. machine machine

    View full-size slide

  30. machine machine machine machine machine machine

    View full-size slide

  31. machine machine machine machine machine machine
    Kubernetes

    View full-size slide

  32. machine machine machine machine machine
    kubelet

    View full-size slide

  33. kubelet kubelet kubelet kubelet kubelet kubelet

    View full-size slide

  34. kubelet kubelet kubelet kubelet kubelet kubelet
    Kubernetes Master

    View full-size slide

  35. kubelet kubelet kubelet kubelet kubelet kubelet
    Kubernetes Master
    etcd

    View full-size slide

  36. kubernetes
    service service service service service service
    service
    service
    service service

    View full-size slide

  37. kubernetes
    service service service service service service
    service
    service
    service service

    View full-size slide

  38. kubernetes
    service service service service service service
    service
    service
    service service

    View full-size slide

  39. kubernetes
    service service service service service service
    service
    service
    service service

    View full-size slide

  40. kubernetes
    service service service service service service
    service
    service
    service service service
    service
    service

    View full-size slide

  41. kubernetes
    service service service service service
    service service service
    service
    service

    View full-size slide

  42. Reliable inter-service
    communication

    View full-size slide

  43. Service
    Service

    View full-size slide

  44. Service
    Service Service
    Service

    View full-size slide

  45. Service
    Service Service
    Service
    Kubernetes

    Service

    View full-size slide

  46. Service Discovery
    Load Balancing
    Timeouts and Expirations
    Retries
    Rate Limiting
    Connection Pooling
    Circuit Breaking
    Failure Detection
    Metrics and Tracing
    Interrupts
    Context Propagation

    View full-size slide

  47. Service Discovery
    Load Balancing
    Timeouts and Expirations
    Retries
    Rate Limiting
    Connection Pooling
    Circuit Breaking
    Failure Detection
    Metrics and Tracing
    Interrupts
    Context Propagation

    View full-size slide

  48. Service
    Service Service
    Service
    ?

    View full-size slide

  49. Service
    Service Service
    Service
    linkerd

    View full-size slide

  50. Service
    linkerd

    View full-size slide

  51. Service
    linkerd
    service

    discovery

    View full-size slide

  52. Service
    Service Service
    Service
    linkerd
    service

    discovery

    View full-size slide

  53. Service
    Service Service
    Service
    linkerd

    View full-size slide

  54. Service
    Service Service
    Service
    linkerd

    View full-size slide

  55. Service
    Service Service
    Service
    linkerd

    View full-size slide

  56. Service
    Service Service
    Service
    linkerd

    View full-size slide

  57. Event Driven

    Architecture

    View full-size slide

  58. Service
    A
    Service
    B
    Load Balancer
    Edge Gateway
    API
    Service

    View full-size slide

  59. API
    Service
    Service
    A
    Service
    B
    Load Balancer
    Edge Gateway

    View full-size slide

  60. API
    Service
    Service
    A
    Service
    B
    Load Balancer
    Edge Gateway
    Service
    D
    Service
    E

    View full-size slide

  61. API
    Service
    Service
    A
    Service
    B
    Load Balancer
    Edge Gateway
    Service
    C
    Service
    D
    Service
    E

    View full-size slide

  62. API
    Service
    Service
    A
    Service
    B
    Load Balancer
    Edge Gateway
    Service
    C
    Service
    D
    Service
    E

    View full-size slide

  63. API
    Service
    Service
    A
    Service
    B
    Load Balancer
    Edge Gateway
    Service
    C
    Service
    D
    Service
    E


    View full-size slide

  64. API
    Service
    Service
    A
    Service
    B
    Load Balancer
    Edge Gateway
    Service
    C
    Service
    D
    Service
    E





    View full-size slide

  65. API
    Service
    Service
    A
    Service
    B
    Load Balancer
    Edge Gateway
    Service
    C
    Service
    D
    Service
    E





    Service
    D

    View full-size slide

  66. API
    Service
    Service
    A
    Service
    B
    Load Balancer
    Edge Gateway
    Service
    C
    Service
    D
    Service
    E

    Service
    D

    View full-size slide

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

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

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

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

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

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

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

  74. Critical Path

    View full-size slide

  75. How do we make
    systems reliable?

    View full-size slide

  76. Masterless systems
    No single points of failure
    Simple / small components
    Minimise critical path
    Queue deferrable tasks
    Automated failure correction

    View full-size slide