HOW TO DISASSEMBLE
A MONOLITHIC APP IN
(NOT-SO)MICRO-SERVICES
Turin - 17 november 2015
MICHELE
FRANZIN
@REALFUZZY
PARTNERS
8000
TRANSACTIONS/MONTH
in just an hour
DISCLAIMER
my personal opinion
people have different experiences
ideas, comment, etc contact me @realfuzzy
subject is wide, so I’d love to hear your thoughts :-)
It’s not a code talk (but I’ll show you some code)
AGENDA:THERE’S NO
AGENDA
I’ve got a tale instead
BUAHAHAHAHA!
I AM THE
MONOLITH!
COME TO THE
WORLD TO BRING
IMMOBILISM AND
COMPLEXITY!
MONOLITHIC MICROSERVICE
architecture is the keyword
ARCHITECTURE ARCHITECTURE
THE
MONOLITH
THE (SOMETIMES EVIL) MONOLITH
http://www.infoq.com/articles/microservices-intro
✓simple to develop
✓IDEs & development tools support
✓easy to test
✓simple to deploy
✓works well for relatively small apps
- growth overloads everything
- difficult to adopt new technologies
- often stuck with the starting choices
- doesn’t scale to long-lived-application
#MICROSERVICE
SEARCHTREND
WHAT’S A MICROSERVICE
• suite of small services
• running in its own process
• communicating with lightweight mechanisms
• built around business capabilities
• independently automated deployable
• minimum of centralized management
• technology agnostic
http://blog.arungupta.me/monolithic-microservices-refactoring-javaee-applications/
✓each microservice is relatively small
✓easier for a developer to understand
✓easier to scale development
✓improve fault isolation
✓develop and deploy independently
✓no long-term commitment to a tech-stack
✓allow a fine-grained performance tuning or scaling
- additional complexity of a distributed system
- tools/IDEs are monolithic applications oriented
- testing is more difficult
- must implement the inter-service communication
- increase memory consumption
THE NEW
BEGINNING
https://upload.wikimedia.org/wikipedia/commons/6/67/Change_In_Hand.jpg
GOALS
‣ time
‣ budget
‣ shit (can) happens
‣ ship
AGENDA*
✓ what’s a microservice?
• why have I to jump in ?
• where I can start from ?
• how I should be aware of ?
* I know, I know, I lied about the agenda
Sir. Tools
A warrior that can
use every kind of
tool as a weapon
Strateky Sensei
Master renowned
for its strategic and
tactical ability
Workodoo Master
The work-force is
strong with this one
HAHAHAHA!
YOUR EFFORTS
ARE NOT
ENOUGH TO
DEFEAT ME!
Your efforts have little effect!
an orthogonal approach might
help you ...
Q0: HOW TO DECOMPOSE A
MONOLITH?
1. Identify business boundaries
2. start decomposing each into own microservice
3. follow the Single Responsibility Principle
4. goto :2
…MANY
SERVICES THAT
COMMUNICATE ?
http://www.raptorsrepublic.com/
ASYNC MESSAGING
XP
S2
S1
CHOOSE WISELY
• Reliability
• Routing algorithms
• Highly Availability
• Supported protocols
MESSAGE BUS
XP1
S2
S1
P2
S3
OUR CHOICE ☛ RABBITMQ
• AMPQ message broker
• Erlang
• Fast, reliable, secure
• Many clients
• Commercial support
SPECIFICATION
IS A MUST HAVE
(no matter what)
DESIGN FOR FAILURE
aka: communicate when communication is hard
CIRCUIT BREAKER
https://www.flickr.com/photos/leafbug/409950515/
http://martinfowler.com/bliki/CircuitBreaker.html
SLIM FIT
circuit_breaker https://github.com/
wsargent/circuit_breaker
breaker_box https://github.com/
sittercity/breaker_box
CB2 https://github.com/pedro/cb2
S
M
L
STOPLIGHT
https://github.com/orgsync/stoplight
–Giovanni Mela
“Inserisci qui una citazione”.
9XL
– Martin Fowler, Chief Scientist -ThoughtWorks
“…don’t even consider microservices
unless you have a system that's too
complex to manage as a monolith”
YAGNI
do monolith first
monolith
microservice
complexity
productivity
http://martinfowler.com/bliki/MicroservicePremium.html
CONTINUOUS DEPLOYMENT
FOR RUBY GEMS
–Giovanni Mela
“Inserisci qui una citazione”.
– Melvin Conway, 1968
“organizations which design systems …
are constrained to produce designs
which are copies of the communication
structures of these organizations”
THE INVERSE
CONWAY MANEUVER
– Martin Fowler, Chief Scientist -ThoughtWorks
“For many people throwing away a code
base is a sign of failure, perhaps
understandable …, but still failure.”
SACRIFICIAL
ARCHITECTURE
http://www.cardhub.com/edu/credit-cards-expiration-date
POLYGLOT IS NICE
but mother tongue is fair enough
DEVOPS!
no devops?!? no party.
https://www.flickr.com/photos/91657289@N02/10218392744
The Smith
Master craftsman
expert in forging
anything
The Sculptor
An artist able to
give shape to
magnificent works
The Painter
Colors and shapes
come to life on her
canvas!
NO MONOLITHS WERE
HARMED INTHE MAKING
OFTHIS PRESENTATION
andreabrigu@gmail.com
@BriguGraphic
Illustrated by:
TAKEAWAYS
• go monolith first
• communication (all-around) is strategic assets
• start simple, don’t fear the change
• take decisions. I-really-mean-that.
…WHAT’S NEXT ?
• testing
• CQRS + ES
• log analisys & monitoring
• metrics
• …
Thank you.
@realfuzzy
Michele Franzin

Come ti smantello un'app monolitica in microservices