前言 .......................................................................................... 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
· · · · · · (
收起)