microservicios, en qué lío me he metido

70
9 y 10 de febrero #T3chFest2017 9 y 10 de febrero #T3chFest2017 9 y 10 de febrero #T3chFest2017 Microservcios, en qué lío me he metido. Ernesto Hernández Packlink Miguel Ortega Packlink

Upload: ernesto-hernandez-rodriguez

Post on 16-Apr-2017

172 views

Category:

Software


0 download

TRANSCRIPT

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

Microservcios, en qué lío me he metido.

Ernesto HernándezPacklink

Miguel OrtegaPacklink

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

LabelsTrackingPayments: Credit card, Paypal, DeferredInvoicingE-commerces integrationAutocomplete rulesZip codes

NOT JUST A SIMPLE CARRIER COMPARATOR

9 y 10 de febrero#T3chFest2017

● 7 Countries

● Over 50 carriers

● >300 shipping services

● >500% shipment grow

● >2M shipments/year

9 y 10 de febrero#T3chFest2017

http://transformcustomers.com/category/business-transformation/ 9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

Our legacy old

Monolith

http://isijisan.blogspot.com.es/2015/03/el-escarabajo-pelotero.html

9 y 10 de febrero#T3chFest2017

Fast growth

9 y 10 de febrero#T3chFest2017

Our shiny and new

Monolith

https://mekubal.wordpress.com/2012/04/03/the-myth-of-monolithic-judaism/

KOKUDO

9 y 10 de febrero#T3chFest2017

Our Monoliths

KOKUDO

9 y 10 de febrero#T3chFest2017

Business needs!!! We need an API

9 y 10 de febrero#T3chFest2017Sometimes you need to clean up

9 y 10 de febrero#T3chFest2017

● Another monolith

● ESB orchestration

● DB coupling

● Fixed deploy dates

● Something distributed

● More choreography

● Different storages

● Deploy flexibility

9 y 10 de febrero#T3chFest2017

It seems clear right?

Microservices

9 y 10 de febrero#T3chFest2017

2014 2015 2016

9 y 10 de febrero#T3chFest2017but what the hell is a microservice?

CHALLENGE ACCEPTED

9 y 10 de febrero#T3chFest2017

Phase 1

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

Phase 2

9 y 10 de febrero#T3chFest2017

● ONE DATABASE● STILL A MONOLITH

FATAL

9 y 10 de febrero#T3chFest2017

Phase 3

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

● NO REAL MICROSERVICES● DEPLOY/CONFIGURATION HELL

ERROR

9 y 10 de febrero#T3chFest2017

Turn

Around

9 y 10 de febrero#T3chFest2017

Phase 4

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

Synchronous calls

Network call

9 y 10 de febrero#T3chFest2017

Synchronous calls

Network call

9 y 10 de febrero#T3chFest2017

Phase 4

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

● SYNCHRONOUS CALLS HELL● WHERE ARE MY JOINS?

warning

9 y 10 de febrero#T3chFest2017

Asynchronous

MESSAGE BUS

9 y 10 de febrero#T3chFest2017

Phase 5

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

Event Driven ArchitectureApps generates events when an action occurs.

Events are published to a message bus

Events represent things that happened in our apps like “client.created”

Other apps can react to this events with other actions or creating materialized views

9 y 10 de febrero#T3chFest2017

New apps can only receive events since the time that was introduced in our platform

Materialized view for the new microservice it’s not complete

What about a new microservice ?

9 y 10 de febrero#T3chFest2017

Event store

Apps events are stored in an event log

9 y 10 de febrero#T3chFest2017

Event store

Apps events are stored in an event log

Events are appended at the end of the log

9 y 10 de febrero#T3chFest2017

If a new service is added to the platform, it`s materialized view can be recreated with the past events

Event store - adding a new app

Apps events are stored in an event log

Events are appended at the end of the log

9 y 10 de febrero#T3chFest2017

Benefits

• Materialized views

• Rebuild app state

• Stream processing

• CEP

9 y 10 de febrero#T3chFest2017

“Distributed transactions”

• Avoid 2 phase commit !!!

• Do compensating

transactions instead

9 y 10 de febrero#T3chFest2017

Event Sourcing

https://martinfowler.com/articles/201701-event-driven.html

http://microservices.io/patterns/data/event-driven-architecture.html

9 y 10 de febrero#T3chFest2017

The Platform

9 y 10 de febrero#T3chFest2017

Docker Ecosystem FTW

● build once, run everywhere

● easy scaling with docker-compose

● infrastructure scaling with swarm

9 y 10 de febrero#T3chFest2017

Hashicorp Consul

- Key/Value (backed by git repo)

- consul-template

- Leader election

- DNS

- Already needed for docker swarm

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

Service discovery

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

How do I develop locally?

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

New old problems

● Onboarding new developers

● Config management

● Debugging

● Data Bootstrapping

9 y 10 de febrero#T3chFest2017

What do we need?

● Infrastructure Bootstrapping:

○ up and running

○ configuration

● Microservices Bootstrapping:

○ up and running

○ application data

9 y 10 de febrero#T3chFest2017

How do we solved it?

● Infrastructure Bootstrapping.

○ up and running

○ configuration

● Microservices Bootstrapping:

○ up and running

○ application data

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

How do we solved it?

● Infrastructure Bootstrapping.

○ up and running

○ configuration

● Microservices Bootstrapping:

○ up and running

○ application data

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

Platform versioning

• microservices.yml - v 2.1.4• search-engine v 2.3.1

• client v 4.2.3

• infrastructure.yml - v 2.1.4• percona v 5.6

• rabbitmq v 3.5

• config repo - v 2.1.4

Packlink v 2.1.4

9 y 10 de febrero#T3chFest2017

Local development

9 y 10 de febrero#T3chFest2017

Service discovery (review)

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

Local development with your IDE

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

Tunnel

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

Service discovery (all together)

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

● DUDE, WHERE ARE MY LOGS?

DEBUG

9 y 10 de febrero#T3chFest2017

Logging stack

9 y 10 de febrero#T3chFest2017

Correlation id

Network call{ correlation_id: 123, ... }

{ correlation_id: 123, ... }{ correlation_id: 123, ... }

{ correlation_id: 123, ... }

{ correlation_id: 123, ... }

{ correlation_id: 123, ... }

9 y 10 de febrero#T3chFest2017

● Make your application log-aggregator agnostic

FATAL

9 y 10 de febrero#T3chFest2017

● How do I trace a single request?

TRACE

9 y 10 de febrero#T3chFest2017

Distributed tracing

9 y 10 de febrero#T3chFest2017

Our (helpful) Dev Tools

9 y 10 de febrero#T3chFest2017

https://slack.com

9 y 10 de febrero#T3chFest2017

Wiggumbot

https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+pluginhttp://docs.sonarqube.org/display/PLUG/GitHub+Plugin9 y 10 de febrero

#T3chFest2017

(Our personal code-reviewer guardian)

9 y 10 de febrero#T3chFest2017

Hound

https://github.com/etsy/hound

Etsy, Inc.

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

Asciidoctor

http://asciidoctor.org9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

Was it worth it?

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

# Shipments

9 y 10 de febrero#T3chFest2017

# Deployments

2 → ~20 per week

9 y 10 de febrero#T3chFest2017

Thank you

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

It seems clear right?

Q&A

9 y 10 de febrero#T3chFest2017

9 y 10 de febrero#T3chFest2017

WE ARE HIRING