Microservices - Peixe Urbano Tech Talks

45
Microservices PU Tech Talks

Transcript of Microservices - Peixe Urbano Tech Talks

Page 1: Microservices - Peixe Urbano Tech Talks

MicroservicesPU Tech Talks

Page 2: Microservices - Peixe Urbano Tech Talks

What is a microservice?

Page 3: Microservices - Peixe Urbano Tech Talks

" (...) an approach to developing a single application as

a suite of small services, each running in its own

process and communicating with lightweight

mechanisms, often an HTTP resource API."

Microservices Architecture Definition

Martin Fowler

Source: http://martinfowler.com/articles/microservices.html

Page 4: Microservices - Peixe Urbano Tech Talks

What problems microservices

can solve ?

Page 5: Microservices - Peixe Urbano Tech Talks

Microservices help us to componentize our application

avoiding the problems created by monolith architectures.

Microservices Architecture Definition

Page 6: Microservices - Peixe Urbano Tech Talks

But what is a component ?

Page 7: Microservices - Peixe Urbano Tech Talks

A component is:

Something independently replaceable. Something independently upgradeable.

Page 8: Microservices - Peixe Urbano Tech Talks

How to identify a monolith design?

Page 9: Microservices - Peixe Urbano Tech Talks

In a monolith architecture, our components

are defined as libraries.

Page 10: Microservices - Peixe Urbano Tech Talks

deployed into a

single

application.

All pieces of

your code

organized as

libraries ...

Componentization via Libraries

Page 11: Microservices - Peixe Urbano Tech Talks

Classic Monolithic Architecture

Page 12: Microservices - Peixe Urbano Tech Talks

And what are the problems with a

monolith design?

Page 13: Microservices - Peixe Urbano Tech Talks

What happens when we need to scale this?

Page 14: Microservices - Peixe Urbano Tech Talks

Node 1 Node 2

Node 3 Node N

We got this!

x N =

...

Page 15: Microservices - Peixe Urbano Tech Talks

Scaling costsAll resources need to be deployed into each new node.

Code complexityYou need to work on a large code base.

Application availabilityYou need to shut down all resources every deploy.

Coupling codeEasy to violate code boundaries.

Long QA cyclesEach change in the code needs to be tested throughout the application.

Monolithic Architecture Problems

Page 16: Microservices - Peixe Urbano Tech Talks

How to identify a microservice

design?

Page 17: Microservices - Peixe Urbano Tech Talks

In a microservices architecture, our

components are defined as services.

Page 18: Microservices - Peixe Urbano Tech Talks

All pieces of your

code organized

as services.

Componentization via Services

Page 19: Microservices - Peixe Urbano Tech Talks

Microservices Architecture

Page 20: Microservices - Peixe Urbano Tech Talks

Are microservices just about a

clean code?

Page 21: Microservices - Peixe Urbano Tech Talks

NO.

Microservices are about teams organization.

Microservices rethink data organization.

Microservices allow technology plurality.

Page 22: Microservices - Peixe Urbano Tech Talks

Teams organized around functions turn into ...

Microservices are about teams organization

Page 23: Microservices - Peixe Urbano Tech Talks

… teams organized around business capabilities.

Microservices rethink teams organization

Page 24: Microservices - Peixe Urbano Tech Talks

Source: http://martinfowler.com/articles/microservices.html

Microservices rethink data organization

Page 25: Microservices - Peixe Urbano Tech Talks

Source: Yow Conference Dec 2013 Netflix Workshop

http://pt.slideshare.net/adrianco/yowworkshop-131203193626phpapp01-1

Microservices allow technology plurality

Page 26: Microservices - Peixe Urbano Tech Talks

But be careful:

Just because you can use a complex stack of

technologies, doesn't mean you should.

Page 27: Microservices - Peixe Urbano Tech Talks

Why not?

Page 28: Microservices - Peixe Urbano Tech Talks

Matt Ranney, Chief Systems Architect at Uber - souce:

https://www.infoq.com/articles/podcast-matt-ranney

Multiple techs come at a price

"A lot of things in engineering is a trade of. A lot of trade

of were not obvious. (...) I hadn't expected the cost of

using multiple languages for microservices to be so high"

Page 29: Microservices - Peixe Urbano Tech Talks

How to manage multiple

microservices at the same time ?

Page 30: Microservices - Peixe Urbano Tech Talks

First: Infrastructure Automation

Page 31: Microservices - Peixe Urbano Tech Talks

Allows automated deployment into:

Instances Virtual Machines Containers

Infrastructure Automation

TestsContinuous

Integration

Continuous

Delivery

Simple to launch

Hard to isolate from

other resources

Consumes all

available resources

Easy to scale - just

add more VMs

VMs have slow

startups

Easy CPU and

memory control

Easy to scale - just

add more containers

Insanely fast to build

and start.

Easy CPU and

memory control

Page 32: Microservices - Peixe Urbano Tech Talks

Second: Sophisticated monitoring

Page 33: Microservices - Peixe Urbano Tech Talks

Services can fail anytime.

With problems that were not anticipated.

Page 34: Microservices - Peixe Urbano Tech Talks

Your monitoring must be:

Realtime Instance level Service level

on:

Architectural elements Business elements

Requests per second

Disc I/O

CPU usage

Sales per minute received

Number of sessions alive

Users navigation stats

Page 35: Microservices - Peixe Urbano Tech Talks

What if I need to process something

through multiple services?

Page 36: Microservices - Peixe Urbano Tech Talks

Monoliths usually solve this problem

with orchestration

Page 37: Microservices - Peixe Urbano Tech Talks

Order Service

new

order

Orchestration design

Payment

ServiceStock Service

Delivery

Service

One service orchestrates a

process flow throughout

the application.

Page 38: Microservices - Peixe Urbano Tech Talks

But microservices usually prefer

choreography over orchestration

Page 39: Microservices - Peixe Urbano Tech Talks

Workflow service

Choreography design

new

order

Order ServicePayment

ServiceStock Service

Delivery

Service

Publishes Subscribes Subscribes Subscribes

Page 40: Microservices - Peixe Urbano Tech Talks

With multiple services we need to be

prepared to fail.

Page 41: Microservices - Peixe Urbano Tech Talks

What happens if we

have a network

failure here ?

Or a timeout

here ?

Or an internal

error here ?

Design for failure

Workflow service

Order ServicePayment

ServiceStock Service

Delivery

Service

Page 42: Microservices - Peixe Urbano Tech Talks

Ok, let's be honest: What problems

could a microservice design bring?

Page 43: Microservices - Peixe Urbano Tech Talks

Microservices general criticism

it's complex to manage due to its distributed nature.

It's hard to keep transactional control over your data.

Inter-service calls over a network have a higher cost in terms

of latency and message processing time than in-process

calls.

Multiple message formats.

Moving responsibilities between services is more

difficult.

Page 44: Microservices - Peixe Urbano Tech Talks

QA?

Page 45: Microservices - Peixe Urbano Tech Talks

Thanks.