SlideShare a Scribd company logo
Grudging monkeys
and microservices
@ by Carlo Sciolla
whoami since 2010!
So... µservices, huh?
Ask the architect
“there is nothing new under the sun
-- “Uncle Bob” Martin on Microservices
But then
- smaller, isolated codebases
- stateless & immutable
- no distributed transactions
- polyglot trojan horse
Meet the micromonkeys
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
The Sucker
Meet the first micromonkey: the sucker. He will happily groom anyone who requests it.
The
Sucker™
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™
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™
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™
DEMO TIME!(wish me luck)
The macro picture
How micro is micro?
single app
boundary
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=http://192.168.59.103:8500",
"-jar", "grudger.jar"]
single app
boundary$ lein uberjar
$ docker build
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
(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
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
Terraform
Immutable infrastructure
v1 v2
v1
$ terraform plan
$ terraform apply
$ git commit
Go CD
Automate everything
Continuous Delivery
docker build
automated
infrastructure
Consul
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.
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.
Much more!
Full package
Consul comes with a variety of other extra features that make automation a pleasure. More info and full
documentation at http://consul.io
watches
kv store
distributed
cross datacenter
sweet!
What to explore next
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)))))))
Auto scaling and scheduling
Persistent storage with Flocker
Monitoring (ELK, New Relic..)
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.
Questions?
Thank you!
Carlo Sciolla
Chief Technology Officer
http://skuro.tk
http://sytac.io
@skuro

More Related Content

PDF
Why isn't infosec working? Did you turn it off and back on again?
PDF
Js deobfuscation with JStillery - bsides-roma 2018
PDF
Building Fast, Modern Web Applications with Node.js and CoffeeScript
PDF
Puppet Camp LA 2/19/2015
PDF
Veil-PowerView - NovaHackers
PDF
Codetainer: a Docker-based browser code 'sandbox'
PDF
Real-time Web Application with Socket.IO, Node.js, and Redis
PDF
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)
Why isn't infosec working? Did you turn it off and back on again?
Js deobfuscation with JStillery - bsides-roma 2018
Building Fast, Modern Web Applications with Node.js and CoffeeScript
Puppet Camp LA 2/19/2015
Veil-PowerView - NovaHackers
Codetainer: a Docker-based browser code 'sandbox'
Real-time Web Application with Socket.IO, Node.js, and Redis
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)

What's hot (10)

PDF
Design patterns - Common Solutions to Common Problems - Brad Wood
PDF
Package manages and Puppet - PuppetConf 2015
PPTX
Passwords#14 - mimikatz
PDF
Raúl Siles - Browser Exploitation for Fun and Profit Revolutions [RootedCON 2...
PDF
Chef Conf 2015: Package Management & Chef
PPTX
Adventures in Asymmetric Warfare
PDF
"Powershell kung-fu" - Paweł Maziarz
PPTX
The Ultimate Deobfuscator - ToorCON San Diego 2008
PDF
Wtf is happening_inside_my_android_phone_public
PDF
Writing malware while the blue team is staring at you
Design patterns - Common Solutions to Common Problems - Brad Wood
Package manages and Puppet - PuppetConf 2015
Passwords#14 - mimikatz
Raúl Siles - Browser Exploitation for Fun and Profit Revolutions [RootedCON 2...
Chef Conf 2015: Package Management & Chef
Adventures in Asymmetric Warfare
"Powershell kung-fu" - Paweł Maziarz
The Ultimate Deobfuscator - ToorCON San Diego 2008
Wtf is happening_inside_my_android_phone_public
Writing malware while the blue team is staring at you
Ad

Viewers also liked (13)

PPT
Social Media Strategies for Events - Hanzehogeschool Groningen 290312
PDF
Tendencias O Innovar
PDF
#MayoInOz Opening Keynote
PPTX
Leveraging Social Media Skills
PDF
London Best Places to Work Roadshow | ARM
PDF
Challenges in stereoscopic movie making and cinema
PPT
Finding and Closing Business from the Social Web
PPTX
The Flexible “Motion Offense” as a Core Basketball Strategy
DOC
prof. in eng. proj. mngt., const. mngt.
PDF
Daily Newsletter: 10th January, 2011
PPTX
UX w trudnych warunkach
PDF
Recorte Web - AAM - MediaIN
PDF
XopheLachnitt - Surinformation et maîtrise de l'information 4/4 (2013)
Social Media Strategies for Events - Hanzehogeschool Groningen 290312
Tendencias O Innovar
#MayoInOz Opening Keynote
Leveraging Social Media Skills
London Best Places to Work Roadshow | ARM
Challenges in stereoscopic movie making and cinema
Finding and Closing Business from the Social Web
The Flexible “Motion Offense” as a Core Basketball Strategy
prof. in eng. proj. mngt., const. mngt.
Daily Newsletter: 10th January, 2011
UX w trudnych warunkach
Recorte Web - AAM - MediaIN
XopheLachnitt - Surinformation et maîtrise de l'information 4/4 (2013)
Ad

Similar to Grudging monkeys and microservices (20)

PPTX
Kali Linux - Falconer
PPT
Defending Against Botnets
PDF
Docker app armor_usecase
PPTX
Criminals in the Cloud: Past, Present, and Future
PDF
Docker, Linux Containers, and Security: Does It Add Up?
PPTX
Ethereum Devcon1 Report (summary writing)
PDF
Analysing Ransomware
PDF
How to prevent cyber terrorism taragana
ODP
Sneaky computation
PPT
Making the case for sandbox v1.1 (SD Conference 2007)
PDF
Virtual Machines Security Internals: Detection and Exploitation
PDF
Threat stack aws
PDF
LXC, Docker, security: is it safe to run applications in Linux Containers?
PDF
FOSDEM 2021 - Infrastructure as Code Drift & Driftctl
PDF
Docker, Linux Containers (LXC), and security
PDF
The Golden Ticket: Docker and High Security Microservices by Aaron Grattafiori
PDF
Penetration Testing Project Game of Thrones CTF: 1
PDF
Gnome, linux mobile stacks, and you
PDF
My Minecraft-Smart-Home: Prototyping the Internet of Uncanny Things
PDF
My Minecraft Smart Home: Prototyping the internet of uncanny things - Sascha ...
Kali Linux - Falconer
Defending Against Botnets
Docker app armor_usecase
Criminals in the Cloud: Past, Present, and Future
Docker, Linux Containers, and Security: Does It Add Up?
Ethereum Devcon1 Report (summary writing)
Analysing Ransomware
How to prevent cyber terrorism taragana
Sneaky computation
Making the case for sandbox v1.1 (SD Conference 2007)
Virtual Machines Security Internals: Detection and Exploitation
Threat stack aws
LXC, Docker, security: is it safe to run applications in Linux Containers?
FOSDEM 2021 - Infrastructure as Code Drift & Driftctl
Docker, Linux Containers (LXC), and security
The Golden Ticket: Docker and High Security Microservices by Aaron Grattafiori
Penetration Testing Project Game of Thrones CTF: 1
Gnome, linux mobile stacks, and you
My Minecraft-Smart-Home: Prototyping the Internet of Uncanny Things
My Minecraft Smart Home: Prototyping the internet of uncanny things - Sascha ...

More from Carlo Sciolla (6)

PDF
Codemotion Amsterdam: a conference for the tech community
PDF
Functional Programming with Clojure
KEY
Dispatch in Clojure
PDF
A Dive Into Clojure
PDF
Alfresco the clojure way -- Slides from the Alfresco DevCon2011
KEY
Alfresco the clojure way
Codemotion Amsterdam: a conference for the tech community
Functional Programming with Clojure
Dispatch in Clojure
A Dive Into Clojure
Alfresco the clojure way -- Slides from the Alfresco DevCon2011
Alfresco the clojure way

Grudging monkeys and microservices

  • 4. Ask the architect “there is nothing new under the sun -- “Uncle Bob” Martin on Microservices
  • 5. But then - smaller, isolated codebases - stateless & immutable - no distributed transactions - polyglot trojan horse
  • 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. The Sucker Meet the first micromonkey: the sucker. He will happily groom anyone who requests it. The Sucker™
  • 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. 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. 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™
  • 14. How micro is micro? single app boundary
  • 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=http://192.168.59.103:8500", "-jar", "grudger.jar"] single app boundary$ lein uberjar $ docker build
  • 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. (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. 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
  • 20. Immutable infrastructure v1 v2 v1 $ terraform plan $ terraform apply $ git commit
  • 21. Go CD
  • 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. 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. Much more! Full package Consul comes with a variety of other extra features that make automation a pleasure. More info and full documentation at http://consul.io watches kv store distributed cross datacenter sweet!
  • 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. Auto scaling and scheduling
  • 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.
  • 35. Thank you! Carlo Sciolla Chief Technology Officer http://skuro.tk http://sytac.io @skuro