microservices rubyconf-2013

56
Adventures with micro-Services Mohit Thatte (@mohitthatte) Anand Agrawal (@anand_agrawal) Thought Works Inc.

Upload: mohit-thatte

Post on 10-May-2015

1.013 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Microservices rubyconf-2013

Adventures with

micro-ServicesMohit Thatte (@mohitthatte)

Anand Agrawal (@anand_agrawal)

ThoughtWorks Inc.

Page 2: Microservices rubyconf-2013

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

Page 3: Microservices rubyconf-2013

What?Why?How?When?

Page 4: Microservices rubyconf-2013

What are micro services?services?micro

Page 5: Microservices rubyconf-2013

What are micro services?

services?

micro

Page 6: Microservices rubyconf-2013

What are micro services?

A real thing that does some thing!

services?

micro

Page 7: Microservices rubyconf-2013

What are micro services?

A real thing that does some thing!Implementation Contract

services?

micro

Page 8: Microservices rubyconf-2013

What are micro services?small independent composable

servicesthat do one thing well

Page 9: Microservices rubyconf-2013

Unix philosophyWrite programs that do one thing well.

Write programs that work together.

cat | grep | sed | awk | ...

HTTP is the new pipe!

Page 10: Microservices rubyconf-2013

Single responsibility

Low coupling, high cohesion

Small, well defined interfaces

Object Oriented philosophy

Page 11: Microservices rubyconf-2013

use micro services?Why we

Page 12: Microservices rubyconf-2013

Once upon a time...

Page 13: Microservices rubyconf-2013

lots of legacy, no reuse

not flexible, high cost of change

no one knows how it works

concentrated complexity

90 year old business

Page 14: Microservices rubyconf-2013

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

Page 15: Microservices rubyconf-2013

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

- Jeff Bay

Page 16: Microservices rubyconf-2013

Adventure so far

25 VM’s in production

10 micro-services

one click deployment

60+ VM’s across environments

Page 17: Microservices rubyconf-2013

µService

DB

µService

DB

µService

DB

µService

DB

Page 18: Microservices rubyconf-2013

How did we start?

Page 19: Microservices rubyconf-2013

Solve small, valuable problems

Page 20: Microservices rubyconf-2013

Start with high level services

Page 21: Microservices rubyconf-2013

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

Page 22: Microservices rubyconf-2013

Orders PaymentsCustomersCatalog(Games)

Page 23: Microservices rubyconf-2013

Orders PaymentsCustomers

Legacy

Catalog(Games)

Page 24: Microservices rubyconf-2013

Orders PaymentsCustomers

Legacy Order Processing

Catalog(Games)

Page 25: Microservices rubyconf-2013

Orders PaymentsCustomers

Legacy ResultsOrder Processing

Catalog(Games)

Page 26: Microservices rubyconf-2013

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

Page 27: Microservices rubyconf-2013

single responsibility

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

Page 28: Microservices rubyconf-2013

I can haz code of conduct?

Page 29: Microservices rubyconf-2013

respect service boundaries

focus on contracts

avoid coupling

extract cross cutting concerns

Page 30: Microservices rubyconf-2013

Orders PaymentsCustomers

Communications

Legacy ResultsOrderProcessing

ScheduledJobs

Errorreporting

Catalog(Games)

Page 31: Microservices rubyconf-2013

So many repos, how do you stay productive?

Page 32: Microservices rubyconf-2013

automate, automate, automate...

Page 33: Microservices rubyconf-2013

DevOps #ftw

15 minute dev box setup

spin up a new service in minutes*

Vagrant + Puppet = AWESOME!

Page 34: Microservices rubyconf-2013

feature toggles over branches

Page 35: Microservices rubyconf-2013

client gems

Page 36: Microservices rubyconf-2013

Is that all captain?

Page 37: Microservices rubyconf-2013

add health checks + circuit breaker

Page 38: Microservices rubyconf-2013

loggingcan you trace a request through?

Page 39: Microservices rubyconf-2013

Avoid / Defer

versioning services

manual tinkering on VM’s

Page 40: Microservices rubyconf-2013

How do I make a changeand still stay sane?

Page 41: Microservices rubyconf-2013

Test It!

Page 42: Microservices rubyconf-2013

Unit Tests

Page 43: Microservices rubyconf-2013

Contract Testsis my service doing what it should?

out of container

strictly black box

Page 44: Microservices rubyconf-2013

Integration Testsare all my services playing nicely together?

testing distributed effects

testing async actions

Page 45: Microservices rubyconf-2013

Continuous Integration

IntegrationTests UAT Performance

Production

ServiceTests

Page 46: Microservices rubyconf-2013

Ok, so you tested it, now release it!

Page 47: Microservices rubyconf-2013

Step 1: Set up ze VM’s

Page 48: Microservices rubyconf-2013

Puppet Solo + SSH in a loop

Puppet goes through CI just like app code

Our ideal : ImmutableServer

deploy all or nothing

Page 49: Microservices rubyconf-2013

Step 2: Deploy ze code

Page 50: Microservices rubyconf-2013

Continuous Integration

IntegrationTests UAT Performance

Production

ServiceTests

Page 51: Microservices rubyconf-2013

CI + DevOpsenables

single-click deployment

so easy, our product owner does it!

it just works™

3 mins to production (~25 servers)

Page 52: Microservices rubyconf-2013

“we’re effectively pushing the complexity from the application

into the infrastructure...”- James Lewis

Page 53: Microservices rubyconf-2013

When to use micro-services?

Page 54: Microservices rubyconf-2013

Tradeoffs

benefit cost

small units of reuse/maintain complex infrastructure

grow independently learning curve

scale independently network overhead

independent DB fragmented data

Polyglot

Page 55: Microservices rubyconf-2013

Thanks!

Page 56: Microservices rubyconf-2013

Questions?