Trasformare un'applicazione monolitica in microservices (versione #daje)

Post on 11-Apr-2017

9.337 views 1 download

Transcript of Trasformare un'applicazione monolitica in microservices (versione #daje)

HOW TO DISASSEMBLE A MONOLITHIC APPS IN (NOT-SO) MICRO-SERVICES

ROME 18 - 19 MARCH 2016

MICHELE FRANZIN

@REALFUZZY

INTEREST IN#MICROSERVICES

PARTNERS

12.000TRANSACTIONS/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 you can see some sources)

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!

THE MONOLITH

easy to develop

IDEs & development tools support

easy to test

simple to deploy

works well for

relatively small apps

AFTER A WHILE…

http

://w

ww.

qcod

emag

.it/w

p-co

nten

t/upl

oads

/201

4/09

/fave

la.jp

g

growth overloads everything

difficult to adopt new technologies

often stuck with the starting choices

doesn’t scale to

long-lived application

MONOLITHARCHITECTURE ARCHITECTURE

MICROSERVICEIC

ARCHITECTUREis the keyword

WHY MICROSERVICES

• suite of small services• running in its own process• communicating with lightweight mechanisms• built around business capabilities • independently automated deployable • technology agnostic

EXPECTATIONS

http

://w

ww.

wall

pape

raw

esom

e.com

/wall

pape

rs-a

wes

ome/

relatively small

easier to understand

easier to scale development

improve fault isolation

develop & deploy independently

no vendor lock

improves

tuning & 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

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

– Martin Fowler, Chief Scientist - ThoughtWorks

“…don’t even consider microservices unless you have a system that's too complex to manage as a monolith”

YAGNIdo monolith first

monolith

microservice

complexity

prod

uctiv

ity

http

://m

artin

fow

ler.co

m/b

liki/M

icros

ervic

ePre

mium

.htm

l

– Sam Newman, author of Building Microservices

“I remain convinced that it is much easier to partition an existing […] system than

to do so up front… You have more to work with.”

HOPE vs REALITY

http

://m

artin

fow

ler.co

m/a

rticl

es/d

ont-s

tart

-mon

olith

.htm

l

THE NEWBEGINNING

http

s://u

ploa

d.wiki

med

ia.or

g/w

ikipe

dia/

com

mon

s/6/6

7/Ch

ange

_In_

Han

d.jpg

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

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 ...

…MANY SERVICES THAT COMMUNICATE ?

http

://w

ww.

rapt

orsre

publi

c.com

/

MESSAGING

XP

S2

S1

MESSAGE BUS

XP1

S2

S1

P2

S3

CHOOSE WISELY

• Reliability

• Routing algorithms

• Highly Availability

• Supported protocols

OUR CHOICE ☛ RABBITMQ

• AMPQ message broker

• Erlang

• Fast, reliable, secure

• Many clients

• Commercial support

HERE!

SPECIFICATION IS A MUST(no matter what)

JSON-LD

JSON-API HAL

DIY

DESIGN FOR FAILUREaka: communicate when communication is hard

CIRCUIT BREAKER http

s://w

ww.

flickr.

com

/pho

tos/l

eafb

ug/4

0995

0515

/

http

://m

artin

fow

ler.co

m/b

liki/C

ircuit

Brea

ker.h

tml

STOPLIGHThttps://github.com/orgsync/stoplight

HOW IT LOOKS LIKE

9XL

– 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

.card

hub.c

om/ed

u/cre

dit-ca

rds-e

xpira

tion-d

ate

POLYGLOT IS NICEbut mother tongue is fair enough

DEVOPS!no devops?!? no party.

https://www.flickr.com/photos/91657289@N02/10218392744

CONTINUOUS DEPLOYMENT FOR RUBY GEMS

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 IN THE MAKINGOF THIS PRESENTATION

andreabrigu@gmail.com

@BriguGraphic

Illustrated by:

TAKEAWAYS

go monolith first

communication (all-around) is strategic assets

start simple, then 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