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.

Cloud Native Akka & Kubernetes: the holy grail to elasticity?


Published on

Cloud Native Akka & Kubernetes: the holy grail to elasticity? by Fabio Tiriticco

Have you ever wondered how to actually achieve elasticity on the cloud, outside of your cushy local dev environment?

Akka is the most mature choice to implement the traits of the Reactive Manifesto, thanks to the Actor model. Resilience is enabled by asynchronous message passing and Actor supervision. Location transparency, message routing and the “share nothing” approach enable seamless scalability, but once our app is deployed we need to rely on some external infrastructure to automatically scale up or down our services. At this point, Akka alone is not sufficient anymore. What else do we need?

We found Docker & Kubernetes to be a perfect match for clustered Akka applications running in the cloud. Thanks to the Kubernetes API, one can write infrastructure logic that complements the business logic. This leads to a general approach of infrastructure-as-code tailored to each different business case, which in turn lets companies achieve maximum efficiency and resource usage.

During this talk we will cover features from both Akka and Kubernetes, plus example code in Scala: familiarity with these technologies is recommended. Our example will rely on Google Cloud infrastructure.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Cloud Native Akka & Kubernetes: the holy grail to elasticity?

  2. 2. Notes • My co-speaker is on holiday • Only relevant concepts are introduced • Slides use pseudo-code. Real deal on GitHub @adamsand0r 🎡🍸
  3. 3. About me Fabio Tiriticco Software Developer / Tech Lead @ticofab
  4. 4. The Reactive Manifesto Elasticity: “use just the right amount” 2013, J. Boner, R. Kuhn, D. Farley, M. Thompson
  5. 5. Akka’s building blocks: Actors • contains state & behaviour logic Actor 1 Actor 3 Actor 2 • has an addressable mailbox to receive and send messages myActor3.getName() “Joe” “What is your name?” “My name is Joe” “Bob” “Tim”
  6. 6. My first journey in the Reactive world
  7. 7. My first journey in the Reactive world
  8. 8. My first journey in the Reactive world Phone 1 actor Phone 2 actor Matcher actor Phone 3 actor A possible architecture for CloudMatch Phone 4 actor “You matched with Phone 4, his address is xxx” “You matched with Phone 1, his address is yyy”
  9. 9. Location transparency
  10. 10. Location transparency Actor 1 Actor 2 “Bob” “Tim” // in Scala + Akka timAddress ! WhatIsYourName • Locally • Remotely
  11. 11. Elasticity test system Job source Master Worker Worker HTTP Adjust rate
  12. 12. The Worker class Worker extends Actor { // ... case job: Job => // .. simulate a CPU-intensive workload master ! JobCompleted(job.number) }
  13. 13. Elasticity test system Job source Worker Master Worker Worker Scaling controller ADD NODEREMOVE NODE TOO LITTLE POWER!TOO MUCH POWER!
  14. 14. Issue #1: how to distribute this? Job source Master Worker Worker Scaling controller
  15. 15. Node 1 Akka Cluster to the rescue! • Joining • Up • Leaving • Unreacheable • … Seed Node 1 Seed Node 2 Node 2 Node 3 NOTE: nodes need to know where the seed is
  16. 16. Moving workers to different nodes JVM 2 - worker JVM 3 - worker Job source Master Worker Worker Scaling controller Single JVM JVM 1 - seed Issue #2: how to spin up and shut down nodes?
  17. 17. Docker + Kubernetes • Node provisioning • Resilience • Mainstream adoption • Cloud providers • API
  18. 18. Kubernetes controller Scaling Controller → Kubernetes Controller Job source Master Worker Worker Scaling controller
  19. 19. Kubernetes Controller class KubernetesController extends Actor { case AddNode => // use kubernetes api to scale up case RemoveNode => // use kubernetes api to scale down }
  20. 20. How does the master asks for changes? class Master extends Actor { // to add a node kubernetesController ! AddNode // to remove a node kubernetesController ! RemoveNode }
  21. 21. Kubernetes Architecture Master Actors Kubernetes Controller Worker Worker Worker akka- master-3fw4 akka- worker-1 akka- worker-2 akka- worker-3 Pods akka-master (Deployment) akka-worker (Deployment) Controllers Services DNS HTTP Job Source JVM seed JVMJVMJVM
  22. 22. A glance at the code, then a live recorded demo 📜 📽,
  23. 23. Burndown rate pattern upon changes + - 0
  24. 24. Measurements
  25. 25. HTTP vs Remote Actor Messaging • Actor come with built-in elasticity • Async messaging gives you more control • Less complexity • Actor messages do not necessarily need a response • HTTP is ubiquitous
  26. 26. HTTP vs Remote Actor Messaging •Performance! J. Janssen
  28. 28. And oh, about the holy grail ? No holy grail in software development.
  29. 29. THANKS @ticofab @adamsand0r