To Kill a Monolith: Slaying the Demons of a Monolith with Node.js Microservices on Cloud Foundry
Dismantling the Monolith: Scaling with Microservices
-
Upload
okl-engineering -
Category
Technology
-
view
151 -
download
0
Transcript of Dismantling the Monolith: Scaling with Microservices
![Page 1: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/1.jpg)
{
Dismantling the MonolithScaling with Microservices
Jenny Kim
August 28, 2014
![Page 2: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/2.jpg)
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
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](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/3.jpg)
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](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/4.jpg)
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](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/5.jpg)
The Problem with Monoliths
![Page 6: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/6.jpg)
The Problem with Monoliths
![Page 7: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/7.jpg)
The Problem with Monoliths
![Page 8: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/8.jpg)
The Problem with Monoliths
![Page 9: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/9.jpg)
The Problem with Monoliths
Domain-driven design
Value Objects
Concerns
Entities
Policy Object
DecoratorsData Transfer Object
![Page 10: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/10.jpg)
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](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/11.jpg)
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](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/12.jpg)
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](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/13.jpg)
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](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/14.jpg)
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](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/15.jpg)
The Problem with Monoliths
![Page 16: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/16.jpg)
The Problem with Monoliths
![Page 17: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/17.jpg)
April 8, 2009: “The Louboutin Incident”
The Problem with Monoliths
![Page 18: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/18.jpg)
The Problem with Monoliths
Sales Volume by $/hour at peak by day
![Page 19: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/19.jpg)
The Problem with Monoliths
![Page 20: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/20.jpg)
The Problem with Monoliths
Gilt Transaction Sequence Modules
![Page 21: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/21.jpg)
The Microservice Way
![Page 22: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/22.jpg)
Bounded Contexts
Autonomous components, with their own domain
models and specific responsibilities.
The Monolithic Way
![Page 23: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/23.jpg)
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](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/24.jpg)
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](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/25.jpg)
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](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/26.jpg)
What’s the difference between Microservices and SOA?
The Microservice Way
Microservices ==
SOA for Hipsters?
![Page 27: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/27.jpg)
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](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/28.jpg)
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](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/29.jpg)
Decentralized Data Management
The Microservice Way
![Page 30: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/30.jpg)
Iterating to Microservices
![Page 31: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/31.jpg)
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](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/32.jpg)
Rule 1: Stop the Monolithic Growth
Iterating to Microservices
![Page 33: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/33.jpg)
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](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/34.jpg)
Rule 3: Microservices should only
communicate via well-defined
interfaces.
Iterating to Microservices
![Page 35: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/35.jpg)
Rule 4: Use coarse-grained, loosely-
coupled services.
Iterating to Microservices
![Page 36: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/36.jpg)
Iterating to Microservices
![Page 37: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/37.jpg)
Iterating to Microservices
![Page 38: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/38.jpg)
Iterating to Microservices
![Page 39: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/39.jpg)
Iterating to Microservices
![Page 40: Dismantling the Monolith: Scaling with Microservices](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/40.jpg)
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](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/41.jpg)
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](https://reader033.fdocuments.net/reader033/viewer/2022042607/55a5a9b91a28ab55398b46c3/html5/thumbnails/42.jpg)
Questions / Discussion