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 Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  8. @miciek
    Code → Production
    Collectibles Service
    Live coding

    View Slide

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

    View Slide

  10. @miciek
    Fast, Stable, Real, Documenting

    View Slide

  11. @miciek
    Kubernetes Deployments

    View Slide

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

    View 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 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 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 Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  20. @miciek
    Isolated tests on
    Production
    Live coding

    View 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 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 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 Slide

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

    View 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 Slide

  26. @miciek
    Service Meshes, Sidecars, Proxies

    View Slide

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

    View Slide

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

    View Slide

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

    View 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 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 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 Slide

  33. @miciek
    @miciek
    www.michalplachta.com

    View 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 Slide