Dismantling the Monolith: Scaling with Microservices

Post on 15-Jul-2015

150 views 0 download

Tags:

Transcript of Dismantling the Monolith: Scaling with Microservices

{

Dismantling the MonolithScaling with Microservices

Jenny Kim

August 28, 2014

Schedule

September 11: Refactoring Patterns by Erich Lin

September 25: Cleaning with SPEED! by Lawrence and Diana

October 9: Riveting Topic by YOU!

Email: jennykim@onekingslane.com or

abahouth@onekingslane.com

Level Up Tech Talks

Confluence Wiki

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

Nominate a topic and a speaker!

1. Microservices in a nutshell

2. The problem with monoliths

3. The Microservice Way

4. Iterating to Microservices

5. Questions / Discussion

Agenda

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

The Problem with Monoliths

The Problem with Monoliths

The Problem with Monoliths

The Problem with Monoliths

The Problem with Monoliths

Domain-driven design

Value Objects

Concerns

Entities

Policy Object

DecoratorsData Transfer Object

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

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

Scaling Monoliths1. Horizontal scaling of web and app servers

2. Database replication or sharding

The Problem with Monoliths

The Problem with Monoliths

Monolithic Apps

require scaling the

entire monolith

What if one component

requires much more

resources than the others?

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

The Problem with Monoliths

The Problem with Monoliths

April 8, 2009: “The Louboutin Incident”

The Problem with Monoliths

The Problem with Monoliths

Sales Volume by $/hour at peak by day

The Problem with Monoliths

The Problem with Monoliths

Gilt Transaction Sequence Modules

The Microservice Way

Bounded Contexts

Autonomous components, with their own domain

models and specific responsibilities.

The Monolithic Way

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.

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

The Monolithic Way

Decentralized Governance

Flexibility and freedom to write and build each service in

any language or technology.

What’s the difference between Microservices and SOA?

The Microservice Way

Microservices ==

SOA for Hipsters?

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

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

Decentralized Data Management

The Microservice Way

Iterating to 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

Rule 1: Stop the Monolithic Growth

Iterating to Microservices

Rule 2: Every existing feature that

requires significant rework will be

removed and rewritten as a micro

service.

Iterating to Microservices

Rule 3: Microservices should only

communicate via well-defined

interfaces.

Iterating to Microservices

Rule 4: Use coarse-grained, loosely-

coupled services.

Iterating to Microservices

Iterating to Microservices

Iterating to Microservices

Iterating to Microservices

Iterating to Microservices

How you implement microservices depends on your

context!

Balancing and rebalancing is the key.

Iterating to Microservices

1. Monolithic Problems: complexity!

coupling! testability! scalability!

2. Microservices: small services,

independent deployments,

decentralized governance

3. Iterate to success!

Summary

Questions / Discussion