[Web] Divide a Monolith Application Into Microservices

Using the Strangler Pattern

 

First write the Dependency Graph. For example:

It would be a good idea start `C` module or `A`.

It would be a bad idea starting from `B` or `D`.

 

Monolith Application

Monolith Application

Strangle the Cart

Step 1: Strangle the Shopping Cart into a Microservice

Strangle the Catalog

Step 2: Strangle the Catalog into a Microservice

Strangle the Front End

Step 3: Strangle the Front End into a Microservice

 

Map Your Dependencies

  • It's important to understand the application you're working with before breaking it apart.
  • One strategy is to map out the modules and their dependencies as a directed graph to understand the downstream impact of your changes.

Where to Start?

  • There’s no hard rule: choose the part of the application that makes the most sense to you.
  • Dependency graph serves merely as a guideline on risk based on the number of dependencies.
  • A module with the least dependencies will potentially have the downstream effects meaning less risk.

How to Start?

  • The Strangler pattern is a common and effective way to migrate legacy applications.
  • Rather than replacing your code with a new version, you can gradually replace components of your application.

Shared Code

  • Code duplication can be abstracted into common libraries used across projects.

 

 

Let's plan for how we can refactor a hypothetical e-commerce monolith application.

Build a dependency graph of the system below. Then, using the graph and business context, decide what parts of the application would make the most sense to begin refactoring using the strangler pattern.

(Hint: there’s no “correct” answer for the dependency graph -- use your intuition to draw the relationships. In practice, we may have to also read through code to build these out!)

Architecture of hypothetical e-commerce website
 
Dependency Graph
  • Dependency graphs are one way to help us visualize and make an informed decision
  • We often have to use additional context with regards to business functionality to weigh decisions
  • Database complexity should also be considered for refactors. Services that seem simple may have complicated refactor strategies with their databases.
posted @   Zhentiw  阅读(118)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2020-03-29 [React] Understand the React Hook Flow
2020-03-29 [React] Manipulate the DOM with React refs
2020-03-29 [React] Use a lazy initializer with useState
2020-03-29 [Angular] Configure Anuglar CLI to generate inlineTemplate and inlineStyle
2019-03-29 [PureScript] Introduce to PureScript Specify Function Arguments
2016-03-29 [React] React Router: Named Components
2016-03-29 [React] React Router: Route Parameters
点击右上角即可分享
微信分享提示