Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

We all need friends and Akka just found Kubernetes


Published on

We all feel alone sometimes. Akka got along well with the VM crew ever since it was born, but new friends and fresh ideas are always necessary. Which is why lately Akka loves spending time with Kubernetes! Maybe the reason why they like each other so much is their sharing of core values such as transparent scalability and resilience.

How do these two technologies compare from a Reactive standpoint? Does one supersede the other? In fact, their powers can be combined to design distributed systems all the way from application code to cloud instance.

Published in: Technology
  • Have you ever used the help of ⇒ ⇐? They can help you with any type of writing - from personal statement to research paper. Due to this service you'll save your time and get an essay without plagiarism.
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

We all need friends and Akka just found Kubernetes

  1. 1. We all need friends, and Akka just found Kubernetes
  2. 2. @ticofab ticofab.ioAbout Me Fabio Tiriticco Scala & Akka consultant @ticofab
  3. 3. Distributed Reactive Systems Reactive Programming Actors Async Messaging Non-blocking IO Streaming Transparent clustering Resource Provisioning Zero-downtime deployments Networking Docker Containers Service Discovery Microservices Reactive Community Kubernetes Community
  4. 4. @ticofab ticofab.ioOutline • Reactive Principles • Akka • Kubernetes • Akka & Kubernetes • Elasticity use cases • Resilience use cases • Conclusions
  5. 5. @ticofab Reactive Principles
  6. 6. @ticofab ticofab.ioThe Reactive Manifesto VALUE MEANS FORM
  7. 7. @ticofab ticofab.ioThe Key to Elasticity is Distribution Scale UP Limited by speed of light and heat dissipation Scale OUT 🌍
  8. 8. @ticofab ticofab.ioThe Key to Distribution is Location Transparency MESSAGE DRIVEN = LOCATION TRANSPARENCY = DISTRIBUTION
  9. 9. @ticofab ticofab.ioFault Tolerance vs Resilience “A fault-tolerant component is hit but keeps going, possibly with reduced functionality” “Upon failure, a resilient component is able to jump back to a fully functional fresh state”
  10. 10. @ticofab Akka
  11. 11. @ticofab ticofab.ioWhat is Akka? Reactive Principles Reactive Design Patterns Reactive Building Blocks JVM / application level
  12. 12. @ticofab ticofab.ioLocation Transparency in Akka Actor 1 “John” “John” name? • can only communicate via async messaging • unit of computation Akka’s building blocks are Actors name: Actor 2 • contains logic & state Actor 1 “John” “John” name? name: Actor 2 State isolation & location transparency Single JVM JVM 1 JVM 2
  13. 13. @ticofab ticofab.ioA Cluster of Actors JVM JVM JVMJVM JVM Akka Cluster Akka Cluster Sharding
  14. 14. @ticofab ticofab.ioResilience in Akka Supervisor Actor Actor Every actor is created by its supervisor, to whom failure handling is delegated • Business logic and failure handling are clearly decoupled ➝ easier to test • Flexible ways to react to failure • Failures don’t cascade to other parts
  15. 15. @ticofab ticofab.ioResilience in Akka Skynet actor T1000 actor try { walk(); } catch (OutOfLegsException e) { } legsAvailable = false; pullWithArms(); T800 instance // in T1000 actor walk() // in Skynet supervisor case h: TooManyHolesException => Restart // or another strategy
  16. 16. @ticofab Kubernetes
  17. 17. @ticofab 4 x What is Kubernetes? MENU Auth Service For those in need of security Picture Resizer Service Available in all sizes Uploader Service Sharing is caring Order 1 x Auth Service 2 x Uploader Service Service orchestration 2 to 8 based on appetite Picture Resizer Service
  18. 18. @ticofab ticofab.ioLocation Transparency in Kubernetes VM 1 VM 2 No need to know IP address of VMs Use pod label or a DNS service Pod 4 Actor 1 Pod 5 Actor 2 Actor 3 Pod 1 name: A Pod 2 name: B Pod 3 name: C Pod = Docker image = JVM
  19. 19. @ticofab ticofab.ioElasticity in Kubernetes Frontend service Backend service load balancer
  20. 20. @ticofab ticofab.ioResilience in Kubernetes Frontend service Backend service load balancer
  21. 21. @ticofab Akka & Kubernetes
  22. 22. @ticofab ticofab.ioThe Akka-Kubernetes Stack JVM JVM Pod Pod Pod VM VM Actors JVM Akka node Pods VM Kubernetes node JVM Akka Cluster Actor Actor Actor Actor Actor
  23. 23. @ticofab ticofab.ioKubernetes Helps with Cluster Formation name: akka-node-1 label: mycluster name: akka-node-4 label: mycluster name: akka-node-2 label: mycluster name: akka-node-3 label: myclusterKubernetes API Akka Cluster Bootstrap
  24. 24. @ticofab Elasticity use cases
  25. 25. @ticofab ticofab.ioDistributed Workload Worker 1 Worker 2 Worker N ….Master We want to keep track of the processing rate according to some custom metrics
  26. 26. @ticofab Load balancer pod pod pod Distributed Workload Worker 1 (pod) Master (pod) Worker 2 (pod) Worker N (pod) Master (router) Worker Worker DELEGATION OF ELASTICITY TO INFRASTRUCTURE LEVEL Worker Worker + Example: COLLABORATION BETWEEN APPLICATION AND INFRASTRUCTURE LEVEL Kubernetes API
  27. 27. @ticofab ticofab.ioDistribute Load and Manage State
  28. 28. @ticofab ticofab.ioMy First Journey in the Reactive World (2013)
  29. 29. @ticofab All games images ™ of Nintendo My First Journey in the Reactive World (2013)
  30. 30. @ticofab ticofab.ioEngine Requirements 📱 Hold state for each device (location, matched devices..) 🔄 Allow a FAST bi-directional channel between paired devices 2 1
  31. 31. @ticofab Device service instance 2 Device service instance 1 Actor-based, Stateful Microservice Architecture Websocket Listener 3 2 1 Device 1 Device 3 Device 2 Listener +
  32. 32. @ticofab ticofab.ioStateless Microservice Architecture Device 1 Device Service instance 1 Websocket Listener 3 2 1 Device Service instance 2 Device Service instance 3 Device 3
  33. 33. @ticofab Resilience use cases
  34. 34. @ticofab ticofab.ioScale of Resilience JVM Exceptions JVM Errors Hardware failure Skynet attack Meteorite hits Akka { } Kubernetes[ ] …
  35. 35. @ticofab ticofab.ioReasons for Resilience at the Application Level Restart time seconds Actor milliseconds If it ain’t broken, don’t restart it One does not simply restart things pod issue restart actor issue resumerestart stop
  36. 36. @ticofab Conclusions
  37. 37. @ticofab ticofab.ioApplication Infrastructure🤝
  38. 38. @ticofab ticofab.ioReview of the Akka-Kubernetes Stack Kubernetes is a great infrastructure choice for your clustered application ⚙ It provides location transparency with cluster formation 🖇 It introduces resilience at an infrastructure level ( Akka has a cloud-native programming model, ready to scale from day 1 📬 It enables transparent communication between different nodes of a service 📟 Resilience is built in your service with granular control +
  39. 39. @ticofab ticofab.ioConclusion Akka & Kubernetes together give you superpowers. Superman is a ™ of DC Comics
  40. 40. @ticofab ticofab.ioFurther Work… More Abstractions & Features! • Streaming • Event Sourcing & CQRS • Reactive Streams connectors • Cluster membership • CRDTs • … • Storage • Confidentiality • Rolling rollouts • Automatic rollbacks • DNS management • …
  41. 41. @ticofab ticofab.ioReferences J. Bonér, R. Kuhn, D. Farley, M. Thompson: The Reactive Manifesto R. Kuhn, B. Hanafee, J. Allen “Reactive Design Patterns” Tools: Akka Docker Kubernetes Code example: Resources:
  42. 42. @ticofab .map( ) One last thing… Moving back to Italy?
  43. 43. @ticofab ticofab.ioQ&A @ticofab Thanks!