Transcript

Adventures with

micro-ServicesMohit Thatte (@mohitthatte)

Anand Agrawal (@anand_agrawal)

ThoughtWorks Inc.

Enough about us. What’s in it for you?

What?Why?How?When?

What are micro services?services?micro

What are micro services?

services?

micro

What are micro services?

A real thing that does some thing!

services?

micro

What are micro services?

A real thing that does some thing!Implementation Contract

services?

micro

What are micro services?small independent composable

servicesthat do one thing well

Unix philosophyWrite programs that do one thing well.

Write programs that work together.

cat | grep | sed | awk | ...

HTTP is the new pipe!

Single responsibility

Low coupling, high cohesion

Small, well defined interfaces

Object Oriented philosophy

use micro services?Why we

Once upon a time...

lots of legacy, no reuse

not flexible, high cost of change

no one knows how it works

concentrated complexity

90 year old business

lots of legacy, no reuse

not flexible, high cost of change

no one knows how it works

concentrated complexity

independent small that do one thingcomposable

90 year old business

“A 100k loc app is just 100 1k loc appswaiting to happen”

- Jeff Bay

Adventure so far

25 VM’s in production

10 micro-services

one click deployment

60+ VM’s across environments

µService

DB

µService

DB

µService

DB

µService

DB

How did we start?

Solve small, valuable problems

Start with high level services

When a service starts doing too much, extract a smaller one

Orders PaymentsCustomersCatalog(Games)

Orders PaymentsCustomers

Legacy

Catalog(Games)

Orders PaymentsCustomers

Legacy Order Processing

Catalog(Games)

Orders PaymentsCustomers

Legacy ResultsOrder Processing

Catalog(Games)

Looks like plain old services, what makes them ‘micro’?

single responsibility

1 service = 1 ‘resource’(maybe 2!)

I can haz code of conduct?

respect service boundaries

focus on contracts

avoid coupling

extract cross cutting concerns

Orders PaymentsCustomers

Communications

Legacy ResultsOrderProcessing

ScheduledJobs

Errorreporting

Catalog(Games)

So many repos, how do you stay productive?

automate, automate, automate...

DevOps #ftw

15 minute dev box setup

spin up a new service in minutes*

Vagrant + Puppet = AWESOME!

feature toggles over branches

client gems

Is that all captain?

add health checks + circuit breaker

loggingcan you trace a request through?

Avoid / Defer

versioning services

manual tinkering on VM’s

How do I make a changeand still stay sane?

Test It!

Unit Tests

Contract Testsis my service doing what it should?

out of container

strictly black box

Integration Testsare all my services playing nicely together?

testing distributed effects

testing async actions

Continuous Integration

IntegrationTests UAT Performance

Production

ServiceTests

Ok, so you tested it, now release it!

Step 1: Set up ze VM’s

Puppet Solo + SSH in a loop

Puppet goes through CI just like app code

Our ideal : ImmutableServer

deploy all or nothing

Step 2: Deploy ze code

Continuous Integration

IntegrationTests UAT Performance

Production

ServiceTests

CI + DevOpsenables

single-click deployment

so easy, our product owner does it!

it just works™

3 mins to production (~25 servers)

“we’re effectively pushing the complexity from the application

into the infrastructure...”- James Lewis

When to use micro-services?

Tradeoffs

benefit cost

small units of reuse/maintain complex infrastructure

grow independently learning curve

scale independently network overhead

independent DB fragmented data

Polyglot

Thanks!

Questions?

top related