{%hackmd SybccZ6XD %} <style> .toc > ul > li:first-child { list-style: none; } .toc > ul > li:first-child > a { display: none; } </style> Why Distributed === ###### tags: `essay` `分散式系統` `introduction` > [name=Shueh Chou Lu][time=Jun, 2021] [TOC] --- 參考書籍: [Thomas Hunter. Distributed Systems with Node.js](https://www.booktopia.com.au/distributed-systems-with-node-js-thomas-hunter-ii/ebook/9781492077244.html) 使用 Repo: [distributed-node](https://github.com/evan361425/distributed-node)  ## 說明 傳統上,應用程式皆為同一包程式碼中,這時會造成什麼問題? 1. 修改程式碼時,可能無意間破壞掉其中各個關係的協作,Debug 代價很高 2. 每次交付、部署都會花很長時間 3. 新進員工,或想進入這個專案的門檻(理解專案的時間)提高 整體來說,這樣的做法成本太高了。 ---- 分散式系統,即是把一個大型應用程式,拆成幾個小的服務。 這時仍會遇到傳統做法不會遇到的問題: 1. 風險提高,因服務彼此之間有連結,若 A 服務壞了,B 服務也會壞掉。多一台機器,就多一份機器壞掉的風險 2. 增加溝通需要的時間、風險和流量 3. 本來同一個應用程式,可以共用一份設定檔、程式碼和機敏資料,若服務變多了,該怎麼同步這些共用的檔案 4. 要怎麼知道特定 Request 為什麼會回 500,哪台壞了? 5. 限制特定服務僅能在服務間溝通,而不能對外(VPC) ---- 之後會使用的範例架構若無說明則為: ```mermaid graph TD 0 -- Request --> 1 1 -- Request --> 2 2 -- Response --> 1 1 -- Response --> 0 0[user] subgraph Application 1[web-api] 2[recipe-api] end ``` 講解順序: (後面的「問題x」代表嘗試解決的問題) 1. [Protocol](/ByBYI1A5u) - 不同的服務間,該用什麼方式溝通,問題2 2. [SLA and Load Testing](/r1G7Xlwi_) - 如何證明效率在接受範圍內,問題2 3. [Observability](https://hackmd.io/@Lu-Shueh-Chou/B1F_g5ts_) - Log、Metric 和 Tracing,問題4 4. [Container](https://hackmd.io/@Lu-Shueh-Chou/By4Woyl6d) - 服務變多了,部署上該使用什麼方式,問題1 5. [Container Orchestration](https://hackmd.io/@Lu-Shueh-Chou/rkm_EvFpO) - 容器調度工具,問題1~5
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up