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

Tear down this pyramid... using functions and meshes

Tear down this pyramid... using functions and meshes

In this live coding talk you will learn about techniques you can use to better test your microservice architecture. We will build a stateful HTTP-based Pac-Man game engine from highly isolated and testable components using pure functions, type parameters, side cars and service meshes.

Michał Płachta

October 09, 2018
Tweet

More Decks by Michał Płachta

Other Decks in Programming

Transcript

  1. @miciek
    @miciek
    Michał Płachta
    michalplachta.com
    @miciek
    E2E
    Integration
    Unit
    Tear down this pyramid...
    using functions & meshes
    Tear down this pyramid...
    using functions & meshes

    View full-size slide

  2. @miciek
    In this talk...
    code
    production

    View full-size slide

  3. @miciek
    In this talk...
    code
    functional programming
    immutability
    Scala production
    accidental complexity
    DevOps
    Kubernetes

    View full-size slide

  4. @miciek
    In this talk...
    functions
    functional programming
    immutability
    Scala service meshes
    accidental complexity
    DevOps
    Kubernetes / Linkerd

    View full-size slide

  5. @miciek
    In this talk...
    E2E
    Integration
    Unit

    View full-size slide

  6. @miciek
    Pac-Man Game Server
    Frontend
    Backend
    100ms
    - Grid setup
    - Direction change
    - Movement
    - Multiple games
    - Fetch & render
    - Send direction changes

    View full-size slide

  7. @miciek
    Pac-Man Game Server
    Frontend
    Backend
    100ms
    Collectibles
    100ms
    - Things that can be eaten
    - Dots
    - Fruit (appearing randomly)

    View full-size slide

  8. @miciek
    Code → Production
    Collectibles Service
    Live coding

    View full-size slide

  9. @miciek
    Creating Collectibles service
    code
    - fast HTTP tests
    - No HTTP server
    - No mocking production
    - pacman-collectibles:v1
    - Yaml → K8s

    View full-size slide

  10. @miciek
    Fast, Stable, Real, Documenting

    View full-size slide

  11. @miciek
    Kubernetes Deployments

    View full-size slide

  12. @miciek
    Rolling out Collectibles
    Frontend
    Backend Collectibles
    v1 prod / no collectibles
    v1 prod / no collectibles v1 not used
    player

    View full-size slide

  13. @miciek
    Big Bang
    Frontend
    Backend Collectibles
    v1 prod / no collectibles
    v2 prod / collectibles
    v1 prod / no collectibles
    v2 prod / collectibles
    v1 not used prod
    player

    View full-size slide

  14. @miciek
    What if?
    Frontend
    Backend Collectibles
    v1 prod / no collectibles
    v1 prod / no collectibles v1
    player
    Frontend
    v2 collectibles
    Backend
    v2 collectibles

    View full-size slide

  15. @miciek
    Per-request routing...
    Frontend
    Backend Collectibles
    v1 prod / no collectibles
    v1 prod / no collectibles v1
    Frontend
    v2 collectibles
    Backend
    v2 collectibles
    player
    test player
    (automated)

    View full-size slide

  16. @miciek
    Without Service Sidecar
    Collectibles
    pacman-collectibles:v1

    View full-size slide

  17. @miciek
    With Service Sidecar
    Collectibles
    pacman-collectibles:v1
    Linkerd Sidecar

    View full-size slide

  18. @miciek
    With Service Mesh
    Collectibles
    pacman-collectibles:v1
    Linkerd

    View full-size slide

  19. @miciek
    Per-request routing...
    Frontend
    Collectibles
    v1 prod / no collectibles
    v1
    Frontend
    v2 collectibles
    Player
    test player
    Linkerd

    View full-size slide

  20. @miciek
    Isolated tests on
    Production
    Live coding

    View full-size slide

  21. @miciek
    Rolling out Collectibles
    Frontend
    Collectibles
    v1 prod / no collectibles
    v1
    Frontend
    v2 collectibles
    Player
    normal
    requests
    test player
    requests with
    routing headers
    Linkerd

    View full-size slide

  22. @miciek
    Cherry Picking using Header
    l5d-dtab: /k8s/pacman/http/backend=>/k8s/pacman/http/backend-test
    https://linkerd.io/1/advanced/dtabs/

    View full-size slide

  23. @miciek
    Cherry Picking using Header
    Linkerd
    Service A
    Service B
    Service Y
    Service Z
    Backend v2
    Frontend v2
    Frontend v1
    Collectibles
    l5d-dtab: /k8s/pacman/http/backend=>/k8s/pacman/http/backend-test

    View full-size slide

  24. @miciek
    Communicating Services
    Linkerd
    Service A
    Service B
    Service Y
    Service Z
    Backend v2
    Frontend v2
    Frontend v1
    Collectibles

    View full-size slide

  25. @miciek
    Communicating Services
    Service Discovery
    Circuit Breaking
    Security
    Telemetry
    Linkerd
    Service A
    Service B
    Service Y
    Service Z
    Backend v2
    Frontend v2
    Frontend v1
    Collectibles
    For free:

    View full-size slide

  26. @miciek
    Service Meshes, Sidecars, Proxies

    View full-size slide

  27. @miciek
    Conclusion… what do we really want?
    Fast!
    Stable!
    Quick to read/write!
    Documentation

    View full-size slide

  28. @miciek
    Conclusion… Tearing down the pyramid!
    E2E
    Integration
    Unit

    View full-size slide

  29. @miciek
    New Testing Pyramid
    Real
    Fast
    Stable
    Quick to read/write
    99% production code

    View full-size slide

  30. @miciek
    New Testing Pyramid
    Real
    Fast
    Stable
    Quick to read/write
    99% production code
    No HTTP Servers
    Function parameters
    Abstracting over data
    Routing test traffic
    Isolated tests on PROD
    No Mocking

    View full-size slide

  31. @miciek
    New Testing Pyramid
    Real
    Fast
    Stable
    Quick to read/write
    99% production code
    No HTTP Servers
    Function parameters
    Abstracting over data
    Routing test traffic
    Isolated tests on PROD
    functions
    service meshes
    No Mocking

    View full-size slide

  32. @miciek
    Next steps
    ➔ Play around with https://github.com/miciek/pacman-kubernetes-linkerd project
    ➔ Play with Kubernetes and Linkerd using Katakoda:
    https://www.katacoda.com/stephpr/scenarios/k8s-l5d
    ➔ Play with Kubernetes and Istio using Katakoda
    https://www.katacoda.com/courses/istio/deploy-istio-on-kubernetes

    View full-size slide

  33. @miciek
    @miciek
    www.michalplachta.com

    View full-size slide

  34. @miciek
    @miciek
    Michał Płachta
    michalplachta.com
    @miciek
    Real
    Tear down this pyramid...
    using functions & meshes
    Tear down this pyramid...
    using functions & meshes
    Fast
    Stable
    Quick to read/write
    99% production code

    View full-size slide