diff --git a/docs/micro-services/images/30103116_ZCcM.png b/docs/micro-services/images/30103116_ZCcM.png new file mode 100644 index 0000000..3dd550f Binary files /dev/null and b/docs/micro-services/images/30103116_ZCcM.png differ diff --git a/docs/micro-services/images/Before-and-after-migration.png b/docs/micro-services/images/Before-and-after-migration.png new file mode 100644 index 0000000..c6cced8 Binary files /dev/null and b/docs/micro-services/images/Before-and-after-migration.png differ diff --git a/docs/micro-services/images/Law-of-Holes.png b/docs/micro-services/images/Law-of-Holes.png new file mode 100644 index 0000000..65a6f5f Binary files /dev/null and b/docs/micro-services/images/Law-of-Holes.png differ diff --git a/docs/micro-services/migrating-from-a-monolithic-architecture-to-a-microservices-architecture.md b/docs/micro-services/migrating-from-a-monolithic-architecture-to-a-microservices-architecture.md index 05f2c88..fe517d8 100644 --- a/docs/micro-services/migrating-from-a-monolithic-architecture-to-a-microservices-architecture.md +++ b/docs/micro-services/migrating-from-a-monolithic-architecture-to-a-microservices-architecture.md @@ -15,7 +15,7 @@ Martin Fowler 将这种现代化策略成为绞杀(Strangler)应用,名字 Law of Holes 是说当自己进洞就应该停止挖掘。对于单体式应用不可管理时这是最佳建议。换句话说,应该停止让单体式应用继续变大,也就是说当开发新功能时不应该为旧单体应用添加新代码,最佳方法应该是将新功能开发成独立微服务。如下图所示: -![1](https://oss-weslie.oss-cn-shanghai.aliyuncs.com/data/github_content_pic/Law%20of%20Holes.png) +![1](/images/Law-of-Holes.png) 除了新服务和传统应用,还有两个模块,其一是请求路由器,负责处理入口(http)请求,有点像之前提到的 API 网关。路由器将新功能请求发送给新开发的服务,而将传统请求还发给单体式应用。 @@ -44,7 +44,7 @@ Law of Holes 是说当自己进洞就应该停止挖掘。对于单体式应用 3. 数据访问层——访问基础元素,例如数据库和消息代理。 在表现层与业务数据访问层之间有清晰的隔离。业务层有由若干方面组成的粗粒度(coarse-grained)的 API,内部包含了业务逻辑元素。API 是可以将单体业务分割成两个更小应用的天然边界,其中一个应用是表现层,另外一个是业务和数据访问逻辑。分割后,表现逻辑应用远程调用业务逻辑应用,下图表示迁移前后架构不同:​ -![2](https://oss-weslie.oss-cn-shanghai.aliyuncs.com/data/github_content_pic/Before%20and%20after%20migration.png) +![2](/images/Before-and-after-migration.png) 单体应用这么分割有两个好处,其一使得应用两部分开发、部署和扩展各自独立,特别地,允许表现层开发者在用户界面上快速选择,进行 A/B 测试;其二,使得一些远程 API 可以被微服务调用。 @@ -70,7 +70,7 @@ Law of Holes 是说当自己进洞就应该停止挖掘。对于单体式应用 ​一旦完成粗粒度接口,也就将此模块转换成独立微服务。为了实现,必须写代码使得单体应用和微服务之间通过使用进程间通信(IPC)机制的 API 来交换信息。如图所示迁移前后对比: -![3](https://oss-weslie.oss-cn-shanghai.aliyuncs.com/data/github_content_pic/30103116_ZCcM.png) +![3](/images/30103116_ZCcM.png) 此例中,正在使用 Y 模块的 Z 模块是备选抽取模块,其元素正在被 X 模块使用,迁移第一步就是定义一套粗粒度 APIs,第一个接口应该是被 X 模块使用的内部接口,用于激活 Z 模块;第二个接口是被 Z 模块使用的外部接口,用于激活 Y 模块。 diff --git a/images/30103116_ZCcM.png b/images/30103116_ZCcM.png new file mode 100644 index 0000000..3dd550f Binary files /dev/null and b/images/30103116_ZCcM.png differ diff --git a/images/Before-and-after-migration.png b/images/Before-and-after-migration.png new file mode 100644 index 0000000..c6cced8 Binary files /dev/null and b/images/Before-and-after-migration.png differ diff --git a/images/Law-of-Holes.png b/images/Law-of-Holes.png new file mode 100644 index 0000000..65a6f5f Binary files /dev/null and b/images/Law-of-Holes.png differ