42
{ Dismantling the Monolith Scaling with Microservices Jenny Kim August 28, 2014

Dismantling the Monolith: Scaling with Microservices

Embed Size (px)

Citation preview

Page 1: Dismantling the Monolith: Scaling with Microservices

{

Dismantling the MonolithScaling with Microservices

Jenny Kim

August 28, 2014

Page 2: Dismantling the Monolith: Scaling with Microservices

Schedule

September 11: Refactoring Patterns by Erich Lin

September 25: Cleaning with SPEED! by Lawrence and Diana

October 9: Riveting Topic by YOU!

Email: [email protected] or

[email protected]

Level Up Tech Talks

Confluence Wiki

https://confluence.newokl.com/x/DQG8

Nominate a topic and a speaker!

Page 3: Dismantling the Monolith: Scaling with Microservices

1. Microservices in a nutshell

2. The problem with monoliths

3. The Microservice Way

4. Iterating to Microservices

5. Questions / Discussion

Agenda

Page 4: Dismantling the Monolith: Scaling with Microservices

Microservices are an architectural approach to developing a

single application as a suite of small services.

• Each service runs in its own process

• Communication via lightweight mechanisms

• Service -> single bounded context

• Loosely-coupled and independently deployable

• Minimal central management, technology-agnostic

• Polyglot persistence: each service with its own data store

Microservices in a Nutshell

Page 5: Dismantling the Monolith: Scaling with Microservices

The Problem with Monoliths

Page 6: Dismantling the Monolith: Scaling with Microservices

The Problem with Monoliths

Page 7: Dismantling the Monolith: Scaling with Microservices

The Problem with Monoliths

Page 8: Dismantling the Monolith: Scaling with Microservices

The Problem with Monoliths

Page 9: Dismantling the Monolith: Scaling with Microservices

The Problem with Monoliths

Domain-driven design

Value Objects

Concerns

Entities

Policy Object

DecoratorsData Transfer Object

Page 10: Dismantling the Monolith: Scaling with Microservices

New features and changes become increasingly difficult

to:

1. Accurately Scope

2. Build and integrate in an efficient and safe manner

The Problem with Monoliths

Page 11: Dismantling the Monolith: Scaling with Microservices

Testing Monoliths

• Test suites grow long, slow, flaky

• Quality control and root cause analysis harder as

many features are implemented at the same time

• Increasing reliance on manual regression testing to

ensure no new bugs introduced

• Longer testing and deployment cycles not amenable

to CI or CD

The Problem with Monoliths

Page 12: Dismantling the Monolith: Scaling with Microservices

Scaling Monoliths1. Horizontal scaling of web and app servers

2. Database replication or sharding

The Problem with Monoliths

Page 13: Dismantling the Monolith: Scaling with Microservices

The Problem with Monoliths

Monolithic Apps

require scaling the

entire monolith

What if one component

requires much more

resources than the others?

Page 14: Dismantling the Monolith: Scaling with Microservices

The Problem with Monoliths

Gilt

• Members-only flash

sales site

• Luxury brands at up

to 70% off

• Sales launch at noon

EST

• Members can reserve

physical units for a

limited time, by

adding to cart

Page 15: Dismantling the Monolith: Scaling with Microservices

The Problem with Monoliths

Page 16: Dismantling the Monolith: Scaling with Microservices

The Problem with Monoliths

Page 17: Dismantling the Monolith: Scaling with Microservices

April 8, 2009: “The Louboutin Incident”

The Problem with Monoliths

Page 18: Dismantling the Monolith: Scaling with Microservices

The Problem with Monoliths

Sales Volume by $/hour at peak by day

Page 19: Dismantling the Monolith: Scaling with Microservices

The Problem with Monoliths

Page 20: Dismantling the Monolith: Scaling with Microservices

The Problem with Monoliths

Gilt Transaction Sequence Modules

Page 21: Dismantling the Monolith: Scaling with Microservices

The Microservice Way

Page 22: Dismantling the Monolith: Scaling with Microservices

Bounded Contexts

Autonomous components, with their own domain

models and specific responsibilities.

The Monolithic Way

Page 23: Dismantling the Monolith: Scaling with Microservices

The Monolithic Way

Keep It Small. Keep It Simple.

Services should be small enough for any developer to

easily understand all aspects of the service, and where

rewriting would be straightforward.

Page 24: Dismantling the Monolith: Scaling with Microservices

The Monolithic Way

Communication Not Coupling

Interaction with each other through interfaces (APIs), or

via messaging broker.

(And no, sharing data models with ActiveResource does not count.)

OR

Page 25: Dismantling the Monolith: Scaling with Microservices

The Monolithic Way

Decentralized Governance

Flexibility and freedom to write and build each service in

any language or technology.

Page 26: Dismantling the Monolith: Scaling with Microservices

What’s the difference between Microservices and SOA?

The Microservice Way

Microservices ==

SOA for Hipsters?

Page 27: Dismantling the Monolith: Scaling with Microservices

Independent Deployability and Scalability1. Services must be deployed on-demand, independently,

preferably automatically. (added perk: zero-downtime?)

2. Services can be distributed and scaled independently, as

individual resource-needs dictate.

The Microservice Way

Page 28: Dismantling the Monolith: Scaling with Microservices

Design for Failure1. Distributed systems mean designing for fault tolerance.

2. Any service could fail at any time! (server failure, network

unavailability, etc)

3. Detect failures quickly and if possible, automatically restore

services that go offline.

4. Real-time monitoring, insight and proactive alerts on network

traffic, monitoring of service request latency.

The Microservice Way

Page 29: Dismantling the Monolith: Scaling with Microservices

Decentralized Data Management

The Microservice Way

Page 30: Dismantling the Monolith: Scaling with Microservices

Iterating to Microservices

Page 31: Dismantling the Monolith: Scaling with Microservices

Soundcloud

Iterating to Microservices

Source

“Building Products at SoundCloud —Part I: Dealing with the Monolith”

https://developers.soundcloud.com/blog/building-products-at-soundcloud-part-

1-dealing-with-the-monolith

Page 32: Dismantling the Monolith: Scaling with Microservices

Rule 1: Stop the Monolithic Growth

Iterating to Microservices

Page 33: Dismantling the Monolith: Scaling with Microservices

Rule 2: Every existing feature that

requires significant rework will be

removed and rewritten as a micro

service.

Iterating to Microservices

Page 34: Dismantling the Monolith: Scaling with Microservices

Rule 3: Microservices should only

communicate via well-defined

interfaces.

Iterating to Microservices

Page 35: Dismantling the Monolith: Scaling with Microservices

Rule 4: Use coarse-grained, loosely-

coupled services.

Iterating to Microservices

Page 36: Dismantling the Monolith: Scaling with Microservices

Iterating to Microservices

Page 37: Dismantling the Monolith: Scaling with Microservices

Iterating to Microservices

Page 38: Dismantling the Monolith: Scaling with Microservices

Iterating to Microservices

Page 39: Dismantling the Monolith: Scaling with Microservices

Iterating to Microservices

Page 40: Dismantling the Monolith: Scaling with Microservices

How you implement microservices depends on your

context!

Balancing and rebalancing is the key.

Iterating to Microservices

Page 41: Dismantling the Monolith: Scaling with Microservices

1. Monolithic Problems: complexity!

coupling! testability! scalability!

2. Microservices: small services,

independent deployments,

decentralized governance

3. Iterate to success!

Summary

Page 42: Dismantling the Monolith: Scaling with Microservices

Questions / Discussion