注重体验与质量的电子书资源下载网站
分类于: 设计 职场办公
简介
Akka应用模式:分布式应用程序设计实践指南 豆 7.8分
资源最后更新于 2020-09-10 15:15:02
作者:[美]Michael Nash(迈克尔·纳什)
译者:虞航仲
出版社:电子工业出版社
出版日期:2017-01
ISBN:9787121325298
文件格式: pdf
标签: Akka Actor 编程 架构 计算机 程序设计 响应式 软件设计
简介· · · · · ·
对于想要学习Akka的Java 和 Scala 开发者们,有很多技术资源可供参考,但是如要想知道如何去应用这些技术就需要不同的思维方式了。为了帮助你正确地使用Akka,《Akka应用模式:分布式应用程序设计实践指南》这本实用的实践指南提供了若干高级的设计模式,还包括了如何以及何时应用那些模式去解决在大型分布式系统中遇到的实际问题的一些案例。
目录
前言 .......................................................................................... xvii
第1 章 Actor 模型 ........................................................................1
现实是最终一致的 .................................................................................................1
解构Actor 模型 .....................................................................................................3
所有的计算都在一个actor 中执行 .........................................................................4
actor 之间只能通过消息进行通信 .........................................................................5
actor 可以创建子actor ...........................................................................................6
actor 可以改变自己的状态或行为 .........................................................................8
一切都是actor .......................................................................................................9
Actor 模型的使用 .................................................................................................10
定义清晰的边界 ................................................................................................... 11
何时适合使用Actor 模型 ....................................................................................13
结论 .....................................................................................................................13
第2 章 Akka 简介 .......................................................................15
Akka 是什么......................................................................................................... 15
Akka 是开源的 .............................................................................................. 15
Akka 正在蓬勃发展 .......................................................................................16
Akka 是为分布式设计的 ...............................................................................16
Akka 组件 ............................................................................................................17
Akka actor .....................................................................................................17
子actor .......................................................................................................... 18
remoting :不同JVM 上的actor ....................................................................20
clustering :集群成员的自动化管理 ..............................................................20
Akka HTTP ...................................................................................................24
TestKit ........................................................................................................... 25
contrib ........................................................................................................... 25
Akka OSGi ................................................................................................... 25
Akka HTTP ...................................................................................................26
Akka Streams ................................................................................................26
Akka 实现的Actor 模型 ......................................................................................26
Actor 模型中的Akka actor ..................................................................................26
消息传递 .......................................................................................................27
actor 系统 ...................................................................................................... 28
Akka Typed 项目 .................................................................................................. 28
结论 ....................................................................................................................29
第3 章 分布式领域驱动设计 ........................................................31
DDD 概述 ............................................................................................................31
DDD 的好处 .........................................................................................................32
DDD 组件 ............................................................................................................33
域实体 ..................................................................................................................34
域值对象 .............................................................................................................34
聚合与聚合根 ..................................................................................................... 35
仓储 .....................................................................................................................37
工厂和对象创建 ................................................................................................... 38
域服务 .................................................................................................................. 38
有界上下文 ..........................................................................................................39
结论 ....................................................................................................................41
第4 章 优秀的Actor 设计 ...........................................................43
大系统小做 ..........................................................................................................43
封装actor 中的状态 ............................................................................................44
使用字段封装状态 .......................................................................................44
使用“状态”容器封装状态 ........................................................................47
使用become 封装状态 ................................................................................. 48
将futures 与actors 混合 ............................................................................... 50
Ask 模式和替代方案 ............................................................................................ 54
Ask 模式的问题 ........................................................................................... 55
附带的复杂性 ................................................................................................ 57
Ask 的替代方案 ........................................................................................... 57
命令与事件 .......................................................................................................... 59
构造函数的依赖注入 ....................................................................................61
使用路径查找actor ......................................................................................61
结论 ....................................................................................................................62
第5 章 数据流 ............................................................................63
吞吐量与延迟 ......................................................................................................63
流 .........................................................................................................................64
路由器 ..................................................................................................................66
邮箱 ..................................................................................................................... 68
无界邮箱 ...................................................................................................... 68
有界邮箱 ......................................................................................................69
拉取的工作模式 ..................................................................................................70
背压 .....................................................................................................................73
ack .................................................................................................................73
高水位标记 ...................................................................................................73
队列长度监控 ................................................................................................74
速率监控 ......................................................................................................74
Akka 数据流.........................................................................................................74
源 .................................................................................................................. 75
汇 ..................................................................................................................77
RunnableGraph ............................................................................................. 78
流 ..................................................................................................................79
交叉点 ........................................................................................................... 80
Akka 流中的背压 ......................................................................................... 81
Akka 流的使用 ............................................................................................. 82
结论 .................................................................................................................... 84
第6 章 一致性和可扩展性 ...........................................................85
事务和一致性 ...................................................................................................... 85
强一致性与最终一致性 ....................................................................................... 86
并发性与并行性 ................................................................................................... 86
为什么全局一致的分布式状态影响可扩展性 ...................................................... 86
位置透明性 ......................................................................................................... 87
交付保证 ............................................................................................................. 87
最多投递一次 ................................................................................................ 87
最少投递一次 ................................................................................................ 88
恰好一次交付是不可能的(但可以近似做到) .............................................91
如何近似做到恰好一次交付 .........................................................................91
集群单例 .......................................................................................................92
可扩展性 ..............................................................................................................94
避免全局状态 ............................................................................................... 98
避免共享状态 ............................................................................................... 98
遵循Actor 模型 .............................................................................................99
避免顺序操作 ...............................................................................................99
隔离阻塞型操作 ...........................................................................................99
监控和调优 ..................................................................................................99
集群分片和一致性 ...............................................................................................99
分片 ............................................................................................................. 100
Akka 中的分片 ........................................................................................... 101
分片键的生成 ............................................................................................. 102
分片的分布 ................................................................................................ 103
一致性边界 ................................................................................................. 103
可扩展性边界 ............................................................................................. 104
分片聚合根 ................................................................................................ 105
持久化 ......................................................................................................... 106
钝化 ............................................................................................................. 106
使用集群分片保证一致性 ........................................................................... 107
结论 .................................................................................................................. 109
第7 章 容错 .............................................................................111
故障类型 ........................................................................................................... 112
异常 ............................................................................................................ 112
JVM 中的致命错误 .................................................................................... 113
外部服务故障 ............................................................................................. 113
不符合服务等级协议 .................................................................................. 113
操作系统和硬件级故障 .............................................................................. 114
故障隔离 ........................................................................................................... 114
舱壁模式 .................................................................................................... 114
优雅降级 ..................................................................................................... 117
使用Akka 集群隔离故障 ............................................................................ 119
使用熔断器控制故障 ................................................................................... 119
故障处理 ............................................................................................................ 122
异常处理 ..................................................................................................... 123
外部服务的故障处理 .................................................................................. 128
结论 ................................................................................................................... 131
第8 章 可用性 ..........................................................................133
微服务和单体式应用 ........................................................................................ 133
用有界上下文划分微服务 ................................................................................. 134
细粒度的微服务 ................................................................................................. 135
集群感知路由器 ................................................................................................. 135
分布式数据 ....................................................................................................... 137
优雅降级 ............................................................................................................ 140
部署 ................................................................................................................... 141
分阶段部署/ 滚动重启 ..................................................................................... 142
蓝/ 绿部署 ........................................................................................................ 142
崩溃恢复/ 运维监测 ......................................................................................... 143
健康检查和应用状态页面 .......................................................................... 143
度量 ............................................................................................................ 145
日志 ............................................................................................................. 146
看门狗工具 ................................................................................................. 146
结论 .................................................................................................................. 147
第9 章 性能 ...........................................................................149
隔离瓶颈 ........................................................................................................... 150
优化Akka ......................................................................................................... 150
减少或隔离阻塞型操作 .............................................................................. 150
缩短消息处理时间 ...................................................................................... 151
增加处理消息的actor ................................................................................ 151
派发器 ................................................................................................................ 151
标准派发器 ................................................................................................. 151
固定派发器 ................................................................................................. 153
平衡派发器 ................................................................................................ 154
calling-thread 派发器 .................................................................................. 154
何时使用单独的派发器 .............................................................................. 155
提高并行性 ................................................................................................ 157
结论 .................................................................................................................. 158
后记 ..........................................................................................159
参考文献 ...................................................................................161
关于作者 ...................................................................................162
封面介绍 ...................................................................................163
第1 章 Actor 模型 ........................................................................1
现实是最终一致的 .................................................................................................1
解构Actor 模型 .....................................................................................................3
所有的计算都在一个actor 中执行 .........................................................................4
actor 之间只能通过消息进行通信 .........................................................................5
actor 可以创建子actor ...........................................................................................6
actor 可以改变自己的状态或行为 .........................................................................8
一切都是actor .......................................................................................................9
Actor 模型的使用 .................................................................................................10
定义清晰的边界 ................................................................................................... 11
何时适合使用Actor 模型 ....................................................................................13
结论 .....................................................................................................................13
第2 章 Akka 简介 .......................................................................15
Akka 是什么......................................................................................................... 15
Akka 是开源的 .............................................................................................. 15
Akka 正在蓬勃发展 .......................................................................................16
Akka 是为分布式设计的 ...............................................................................16
Akka 组件 ............................................................................................................17
Akka actor .....................................................................................................17
子actor .......................................................................................................... 18
remoting :不同JVM 上的actor ....................................................................20
clustering :集群成员的自动化管理 ..............................................................20
Akka HTTP ...................................................................................................24
TestKit ........................................................................................................... 25
contrib ........................................................................................................... 25
Akka OSGi ................................................................................................... 25
Akka HTTP ...................................................................................................26
Akka Streams ................................................................................................26
Akka 实现的Actor 模型 ......................................................................................26
Actor 模型中的Akka actor ..................................................................................26
消息传递 .......................................................................................................27
actor 系统 ...................................................................................................... 28
Akka Typed 项目 .................................................................................................. 28
结论 ....................................................................................................................29
第3 章 分布式领域驱动设计 ........................................................31
DDD 概述 ............................................................................................................31
DDD 的好处 .........................................................................................................32
DDD 组件 ............................................................................................................33
域实体 ..................................................................................................................34
域值对象 .............................................................................................................34
聚合与聚合根 ..................................................................................................... 35
仓储 .....................................................................................................................37
工厂和对象创建 ................................................................................................... 38
域服务 .................................................................................................................. 38
有界上下文 ..........................................................................................................39
结论 ....................................................................................................................41
第4 章 优秀的Actor 设计 ...........................................................43
大系统小做 ..........................................................................................................43
封装actor 中的状态 ............................................................................................44
使用字段封装状态 .......................................................................................44
使用“状态”容器封装状态 ........................................................................47
使用become 封装状态 ................................................................................. 48
将futures 与actors 混合 ............................................................................... 50
Ask 模式和替代方案 ............................................................................................ 54
Ask 模式的问题 ........................................................................................... 55
附带的复杂性 ................................................................................................ 57
Ask 的替代方案 ........................................................................................... 57
命令与事件 .......................................................................................................... 59
构造函数的依赖注入 ....................................................................................61
使用路径查找actor ......................................................................................61
结论 ....................................................................................................................62
第5 章 数据流 ............................................................................63
吞吐量与延迟 ......................................................................................................63
流 .........................................................................................................................64
路由器 ..................................................................................................................66
邮箱 ..................................................................................................................... 68
无界邮箱 ...................................................................................................... 68
有界邮箱 ......................................................................................................69
拉取的工作模式 ..................................................................................................70
背压 .....................................................................................................................73
ack .................................................................................................................73
高水位标记 ...................................................................................................73
队列长度监控 ................................................................................................74
速率监控 ......................................................................................................74
Akka 数据流.........................................................................................................74
源 .................................................................................................................. 75
汇 ..................................................................................................................77
RunnableGraph ............................................................................................. 78
流 ..................................................................................................................79
交叉点 ........................................................................................................... 80
Akka 流中的背压 ......................................................................................... 81
Akka 流的使用 ............................................................................................. 82
结论 .................................................................................................................... 84
第6 章 一致性和可扩展性 ...........................................................85
事务和一致性 ...................................................................................................... 85
强一致性与最终一致性 ....................................................................................... 86
并发性与并行性 ................................................................................................... 86
为什么全局一致的分布式状态影响可扩展性 ...................................................... 86
位置透明性 ......................................................................................................... 87
交付保证 ............................................................................................................. 87
最多投递一次 ................................................................................................ 87
最少投递一次 ................................................................................................ 88
恰好一次交付是不可能的(但可以近似做到) .............................................91
如何近似做到恰好一次交付 .........................................................................91
集群单例 .......................................................................................................92
可扩展性 ..............................................................................................................94
避免全局状态 ............................................................................................... 98
避免共享状态 ............................................................................................... 98
遵循Actor 模型 .............................................................................................99
避免顺序操作 ...............................................................................................99
隔离阻塞型操作 ...........................................................................................99
监控和调优 ..................................................................................................99
集群分片和一致性 ...............................................................................................99
分片 ............................................................................................................. 100
Akka 中的分片 ........................................................................................... 101
分片键的生成 ............................................................................................. 102
分片的分布 ................................................................................................ 103
一致性边界 ................................................................................................. 103
可扩展性边界 ............................................................................................. 104
分片聚合根 ................................................................................................ 105
持久化 ......................................................................................................... 106
钝化 ............................................................................................................. 106
使用集群分片保证一致性 ........................................................................... 107
结论 .................................................................................................................. 109
第7 章 容错 .............................................................................111
故障类型 ........................................................................................................... 112
异常 ............................................................................................................ 112
JVM 中的致命错误 .................................................................................... 113
外部服务故障 ............................................................................................. 113
不符合服务等级协议 .................................................................................. 113
操作系统和硬件级故障 .............................................................................. 114
故障隔离 ........................................................................................................... 114
舱壁模式 .................................................................................................... 114
优雅降级 ..................................................................................................... 117
使用Akka 集群隔离故障 ............................................................................ 119
使用熔断器控制故障 ................................................................................... 119
故障处理 ............................................................................................................ 122
异常处理 ..................................................................................................... 123
外部服务的故障处理 .................................................................................. 128
结论 ................................................................................................................... 131
第8 章 可用性 ..........................................................................133
微服务和单体式应用 ........................................................................................ 133
用有界上下文划分微服务 ................................................................................. 134
细粒度的微服务 ................................................................................................. 135
集群感知路由器 ................................................................................................. 135
分布式数据 ....................................................................................................... 137
优雅降级 ............................................................................................................ 140
部署 ................................................................................................................... 141
分阶段部署/ 滚动重启 ..................................................................................... 142
蓝/ 绿部署 ........................................................................................................ 142
崩溃恢复/ 运维监测 ......................................................................................... 143
健康检查和应用状态页面 .......................................................................... 143
度量 ............................................................................................................ 145
日志 ............................................................................................................. 146
看门狗工具 ................................................................................................. 146
结论 .................................................................................................................. 147
第9 章 性能 ...........................................................................149
隔离瓶颈 ........................................................................................................... 150
优化Akka ......................................................................................................... 150
减少或隔离阻塞型操作 .............................................................................. 150
缩短消息处理时间 ...................................................................................... 151
增加处理消息的actor ................................................................................ 151
派发器 ................................................................................................................ 151
标准派发器 ................................................................................................. 151
固定派发器 ................................................................................................. 153
平衡派发器 ................................................................................................ 154
calling-thread 派发器 .................................................................................. 154
何时使用单独的派发器 .............................................................................. 155
提高并行性 ................................................................................................ 157
结论 .................................................................................................................. 158
后记 ..........................................................................................159
参考文献 ...................................................................................161
关于作者 ...................................................................................162
封面介绍 ...................................................................................163