microservices - peixe urbano tech talks

Post on 29-Jan-2018

450 Views

Category:

Software

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

MicroservicesPU Tech Talks

What is a microservice?

" (...) 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

What problems microservices

can solve ?

Microservices help us to componentize our application

avoiding the problems created by monolith architectures.

Microservices Architecture Definition

But what is a component ?

A component is:

Something independently replaceable. Something independently upgradeable.

How to identify a monolith design?

In a monolith architecture, our components

are defined as libraries.

deployed into a

single

application.

All pieces of

your code

organized as

libraries ...

Componentization via Libraries

Classic Monolithic Architecture

And what are the problems with a

monolith design?

What happens when we need to scale this?

Node 1 Node 2

Node 3 Node N

We got this!

x N =

...

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

How to identify a microservice

design?

In a microservices architecture, our

components are defined as services.

All pieces of your

code organized

as services.

Componentization via Services

Microservices Architecture

Are microservices just about a

clean code?

NO.

Microservices are about teams organization.

Microservices rethink data organization.

Microservices allow technology plurality.

Teams organized around functions turn into ...

Microservices are about teams organization

… teams organized around business capabilities.

Microservices rethink teams organization

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

Microservices rethink data organization

Source: Yow Conference Dec 2013 Netflix Workshop

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

Microservices allow technology plurality

But be careful:

Just because you can use a complex stack of

technologies, doesn't mean you should.

Why not?

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"

How to manage multiple

microservices at the same time ?

First: Infrastructure Automation

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

Second: Sophisticated monitoring

Services can fail anytime.

With problems that were not anticipated.

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

What if I need to process something

through multiple services?

Monoliths usually solve this problem

with orchestration

Order Service

new

order

Orchestration design

Payment

ServiceStock Service

Delivery

Service

One service orchestrates a

process flow throughout

the application.

But microservices usually prefer

choreography over orchestration

Workflow service

Choreography design

new

order

Order ServicePayment

ServiceStock Service

Delivery

Service

Publishes Subscribes Subscribes Subscribes

With multiple services we need to be

prepared to fail.

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

Ok, let's be honest: What problems

could a microservice design bring?

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.

QA?

Thanks.

top related