Scalable System Design Patterns
可伸縮系統的設計模式
Ricky Ho在他的博客中分享了該文章,該文章是一個簡單的概括分享,詳細的可以參見他博客的其它詳細文章。下面主要是意譯。
1、Load Balancer:負載均衡 – 由分發者來決定哪個工作者處理下一個請求,這種決定可以基於不同的策略。
“In this model, there is a dispatcher that determines which worker instance will handle the request based on different policies. The application should best be "stateless" so any worker instance can handle the request.
This pattern is deployed in almost every medium to large web site setup.”
該模式中,由分發器來決定哪個工作者來處理請求。應用最好是無狀態的,以使任何一個工作者都能同等處理請求。幾乎所有的中大型網站都應用了負載均衡器這個模式。
2、Scatter and Gather:分散和聚合 – 分發者將請求廣播到處理池當中的所有工作者。每一個工作者單獨計算其中一部分並將結果返回給分發者,由分發者來匯總所有的計算結果並返回。
”In this model, the dispatcher multicast the request to all workers of the pool. Each worker will compute a local result and send it back to the dispatcher, who will consolidate them into a single response and then send back to the client.
This pattern is used in Search engines like Yahoo, Google to handle user's keyword search request ... etc.“
該模式中,分發者將請求轉發給池中的所有工作者,每個工作者處理請求的一部分並返回給分發器,分發器工作者返回的結果加工組合為一個響應返回給客戶端。該模式在搜索引擎中使用處理用戶的關鍵字,如Yahoo、Google。
3、Result Cache:結果緩存 – 分發者會首先檢查這個請求之前是否有處理過,並試圖找出之前的處理結果並返回,以便節省處理時間。
“In this model, the dispatcher will first lookup if the request has been made before and try to find the previous result to return, in order to save the actual execution.
This pattern is commonly used in large enterprise application. Memcached is a very commonly deployed cache server.”
該模式,只是在分發器處理時加了一步查詢結果緩存(譯注:類似瀏覽器緩存),如果之前已經處理過並且可以使用之前的緩存,就返回之前的處理結果節省處理時間!該模式通常使用在大型企業應用。Memcached就是一個常用的cache服務器。
4、Shared Space:共享空間 – 所有的工作者都關注一塊共享區域內的信息,並且都向這塊區域提交自己的部分知識、信息。信息不斷被完善,直到問題可以被解決為止。
“This model also known as "Blackboard"; all workers monitors information from the shared space and contributes partial knowledge back to the blackboard. The information is continuously enriched until a solution is reached.
This pattern is used in JavaSpace and also commercial product GigaSpace.”
這個模式也叫“黑板模式”。就是在處理流程中,存在一個全局傳遞的對象,它可能包含了請求參數、中間狀態、響應結果等各種信息,供流程中的各個組件對其進行操作。該模式在JavaSpace(譯注:JavaSpaces技術是進行分布式計算的一種簡單機制)和GigaSpace(譯注:是一個虛擬化的中間件層)中都有使用。
5、Pipe and Filter:管道和過濾器 – 所有的工作者按照數據處理的流程被串行連接起來。
“This model is also known as "Data Flow Programming"; all workers connected by pipes where data is flow across.
This pattern is a very common EAI pattern.”
這個模式也叫“面向數據流編程”,是很通用的企業集成模式。
6、Map Reduce:專門用於磁盤IO為瓶頸的批處理作業。使用分布式的文件系統使得文件能夠被並行處理。
“The model is targeting batch jobs where disk I/O is the major bottleneck. It use a distributed file system so that disk I/O can be done in parallel.
This pattern is used in many of Google's internal application, as well as implemented in open source Hadoop parallel processing framework. I also find this pattern can be used in many many application design scenarios.”
這個模式使用分布式文件系統,這樣磁盤可以並行I/O。Google內部許多應用程序使用了這個模式。Hadoop就是基於MapReduce的一個實現。
7、Bulk Synchronous Parellel:批量同步並行 – 所有工作者一個接一個的執行,由主控來進行協調。
“This model is based on lock-step execution across all workers, coordinated by a master. Each worker repeat the following steps until the exit condition is reached, when there is no more active workers.
1) Each worker read data from input queue
2) Each worker perform local processing based on the read data
3) Each worker push local result along its direct connection
This pattern has been used in Google's Pregel graph processing model as well as the Apache Hama project.”
該模型基於一個master協調,所有的worker同步(lock-step)執行。
該模式被用於Google Pregel Graph Processing google-pregel-graph-processing和Hama。
8、Execution Orchestrator:執行集中管理 – 一個智能的調度者在一群簡單的工作者上調配已經准備好運行的任務(基於依賴圖)
“This model is based on an intelligent scheduler / orchestrator to schedule ready-to-run tasks (based on a dependency graph) across a clusters of dumb workers.
This pattern is used in Microsoft's Dryad project”
該模式基於一個智能調度者/管理者在一群工作者之間調配可運行任務。該模式在微軟的:Microsoft’s Dryad project中使用。

![clip_image002[4] clip_image002[4]](/image/aHR0cHM6Ly9pbWFnZXMuY25ibG9ncy5jb20vY25ibG9nc19jb20vc2t5bmV0LzIwMTIxMi8yMDEyMTIwNDE3MDg1NzI0MTAucG5n.png)
![clip_image004[4] clip_image004[4]](/image/aHR0cHM6Ly9pbWFnZXMuY25ibG9ncy5jb20vY25ibG9nc19jb20vc2t5bmV0LzIwMTIxMi8yMDEyMTIwNDE3MDg1ODM3MzkucG5n.png)
![clip_image006[4] clip_image006[4]](/image/aHR0cHM6Ly9pbWFnZXMuY25ibG9ncy5jb20vY25ibG9nc19jb20vc2t5bmV0LzIwMTIxMi8yMDEyMTIwNDE3MDg1OTExNjUucG5n.png)
![clip_image008[4] clip_image008[4]](/image/aHR0cHM6Ly9pbWFnZXMuY25ibG9ncy5jb20vY25ibG9nc19jb20vc2t5bmV0LzIwMTIxMi8yMDEyMTIwNDE3MDkwMDMyNTgucG5n.png)
![clip_image010[4] clip_image010[4]](/image/aHR0cHM6Ly9pbWFnZXMuY25ibG9ncy5jb20vY25ibG9nc19jb20vc2t5bmV0LzIwMTIxMi8yMDEyMTIwNDE3MDkwMDQ1ODgucG5n.png)
![clip_image012[4] clip_image012[4]](/image/aHR0cHM6Ly9pbWFnZXMuY25ibG9ncy5jb20vY25ibG9nc19jb20vc2t5bmV0LzIwMTIxMi8yMDEyMTIwNDE3MDkwMTMwOTMucG5n.png)
![clip_image014[4] clip_image014[4]](/image/aHR0cHM6Ly9pbWFnZXMuY25ibG9ncy5jb20vY25ibG9nc19jb20vc2t5bmV0LzIwMTIxMi8yMDEyMTIwNDE3MDkwMjUxOS5wbmc=.png)
![clip_image016[4] clip_image016[4]](/image/aHR0cHM6Ly9pbWFnZXMuY25ibG9ncy5jb20vY25ibG9nc19jb20vc2t5bmV0LzIwMTIxMi8yMDEyMTIwNDE3MDkwMzM4MDAucG5n.png)