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.

Grudging monkeys and microservices


Published on

  • Be the first to comment

Grudging monkeys and microservices

  1. 1. Grudging monkeys and microservices @ by Carlo Sciolla
  2. 2. whoami since 2010!
  3. 3. So... µservices, huh?
  4. 4. Ask the architect “there is nothing new under the sun -- “Uncle Bob” Martin on Microservices
  5. 5. But then - smaller, isolated codebases - stateless & immutable - no distributed transactions - polyglot trojan horse
  6. 6. Meet the micromonkeys
  7. 7. Genesis of an entertaining (?) talk about microservices We’ll explore how to architect and operate microservices following the adventures of three monkeys that need to collaborate to get rid of nasty bugs
  8. 8. The Sucker Meet the first micromonkey: the sucker. He will happily groom anyone who requests it. The Sucker™
  9. 9. The Cheater This micromonkey is fundamentally a bastard. He asks the help of others when in need, but always refuse to groom anyone back. Not. Nice. The Cheater™
  10. 10. The Grudger Our last micromonkey is there to counter antisocial behaviors: if someone refuses to groom when he asks, he will hold a grudge and refuse to groom the cheater afterwards. The Grudger™
  11. 11. Life, a tick at a time Our micromonkeys live a quantised life. The Simulator takes care of notifying the monkeys when it’s time to go one more clock tick ahead. The Simulator™
  12. 12. DEMO TIME!(wish me luck)
  13. 13. The macro picture
  14. 14. How micro is micro? single app boundary
  15. 15. Immutable deployment units It’s my app in a box, babe! Containers give you a unified distribution model across technologies and an efficient way of using your system resources. Together with stateleness, they’re much more easy to hot-deploy than WAR files! command = ["java", "-Dmonkey=grudger", "-Dmonkey-id=1", "-Dmonkey-port=8081", "-Dmonkey-consul-endpoint=", "-jar", "grudger.jar"] single app boundary$ lein uberjar $ docker build
  16. 16. Beware of hidden complexity Extended application domain When you distribute your app as a Docker container, you’re also distributing (a part of) the OS, and as such you’re responsible for it. distro selection security guarantees persistent storage init system kernel panicslinked containers
  17. 17. (def stem-micromonkey ["/" {"" api-index "clock" {:put process-clock :get show-clock} "bugs" {:put add-bugs :delete remove-bugs} "status" status "groom" {:post will-groom} "reborn" {:post resuscitate} "config" show-config}]) REST + (a)sync + P2P REST + HTTPKit + core.async The micromonkeys expose a tiny REST APIs using bidi and talk to each other using synchronous request/response patterns, while the simulator use core.async to interact with them. minimal API fast responses per-node transaction
  18. 18. States catch up: CAP Convergent replicated data type (CvRDT) The micromonkeys only shared state is a counter, treated as monotonically increasing. When the monkey is dead it simulates a partition. As the clock value is sent along the tick request, state is trivially restored. 4242 42 36 43 44 45 36 36 45
  19. 19. Terraform
  20. 20. Immutable infrastructure v1 v2 v1 $ terraform plan $ terraform apply $ git commit
  21. 21. Go CD
  22. 22. Automate everything
  23. 23. Continuous Delivery docker build automated infrastructure
  24. 24. Consul
  25. 25. Service discovery it’s me! it’s me! it’s me! Service registration At bootstrap, each micromonkey registers into Consul, exposing information like their URL, esposed TCP port, what service category (-> monkey type) they are and what health check system to use.
  26. 26. Service discovery Are there alive monkeys? Are there alive monkeys? Multi protocol Consul accepts both HTTP and DNS queries to expose information regarding registered services.
  27. 27. Much more! Full package Consul comes with a variety of other extra features that make automation a pleasure. More info and full documentation at watches kv store distributed cross datacenter sweet!
  28. 28. What to explore next
  29. 29. Fault tolerance Circuit breakers FTW When things go sideways and failures propagate throughout your system, then being distributed won’t improve your resilience. (decommand ask-grooming "Asks a monkey to groom us" [monkey] (let [res-chan (rest/ask-grooming monkey)] (go (let [[response ch] (alts! response-chan (timeout (config/response-timeout)))] (if (= response-chan ch) (process-response ch) (throw (MonkeyTimeoutException. monkey)))))))
  30. 30. Auto scaling and scheduling
  31. 31. Persistent storage with Flocker
  32. 32. Monitoring (ELK, New Relic..)
  33. 33. Inspired by Among the other million links The whole Internet is talking about microservices, but these two offered a similar pattern for a full microservices deployment which inspired the design of the Micromonkeys.
  34. 34. Questions?
  35. 35. Thank you! Carlo Sciolla Chief Technology Officer @skuro