分散式系統 Distributed Systems_Chapter 02: Architectures_Week2筆記

軟體架構 (Software architectures) :
說明各種軟體元件是如何組織的,以及它們應該如何互動。
分散式系統中軟體架構目標: 
透過提供中介層 (middleware layer),將應用程式與底層平台分離。
系統架構(System Architecture)
決定軟體元件、它們之間互動方式,以及它們的部署位置,最終形成一具體的軟體架構實例。
Architectural styles
  • (replaceable) components with well-defined interfaces
    可替換的元件之間透過明確定義的介面彼此互動
  • the way that components are connected to each other
    元件之間的連接方式
  • the data exchanged between components
    元件間交換的資料
  • how these components and connectors are jointly configured into a system.
    系統的整體配置,元件與連接器如何組合成一個完整的系統。
    連接器 (Connector):是一種機制,用來調節元件之間的通訊 (communication)、協調 (coordination)、合作 (cooperation)。例如:用於遠端程序呼叫(RPC)、訊息傳遞(messaging)或資料串流(streaming)的機制。

Layered architecture
  • Pure layered org : Only downcalls to the next lower layer are made.
  • mixed layered org : take layer n-1. There’s an app called A. this will invoke an OS library that’s available in layer n-3. AS WELL as n-3, A will call layer n-2,wihich holds a maths library . maths library itself relies on OS library in layer n-3! So n-2 has to call n-3 as well.
  • layered org with upcall : Have a lower layer do an upcall to its next higher layer


Application Layering
典型的 三層架構(Three-tier architecture):介面層、邏輯層、資料層。
  • 應用介面層(Application-interface layer):包含與使用者或外部應用程式互動的單元。
  • 處理層(Processing layer):包含應用程式的功能,即不依賴特定資料的部分。
  • 資料層(Data layer):包含用戶端希望透過應用程式元件操作的資料。
Centralized system architectures
Client–Server Model
  • 伺服器(Server-Side):負責提供服務的processes
  • 用戶端(Client-Side):負責存取使用、消費服務的processes
  • Clients and servers can be on different machines
  • Clients follow request/reply model with respect to using services
  • 冪等性(Idempotent):某個操作可以被重複執行多次而不會造成額外影響或傷害。
Multi-tiered centralized system architectures
  • Single-tiered: dumb terminal/mainframe configuration
  • Two-tiered: client/single server configuration
  • Three-tiered: each layer on separate machine
    =>例如:Being client and server at the same time
替代性組織方式(Alternative organizations)
  • 垂直分佈(Vertical distribution):不同機器扮演不同角色,將不同層級分散到多台機器上。。
  • 水平分佈(Horizontal distribution):多台機器扮演相似角色。
    Ex:將一個資料庫分散到多台伺服器,以提升效能與可靠性。
  • 點對點架構(Peer-to-peer architectures):所有程序都是平等的。每個程序同時扮演 用戶端(client) 與 伺服器(server) 的角色。並且都具備需要執行的功能。這種雙重角色有時被稱為 「servant」(既是 server 又是 client)。
Structured P2P
  • 有控制的 (controlled) overlay topology,peers 之間的連結是固定的,使用 DHT。
  • Key → 由雜湊函數產生,唯一對應Value (資料項目)。負責將 (key, value) 配對分散儲存在不同節點,並能根據 key 高效檢索。
例如:Chord 是一種 分散式雜湊表(Distributed Hash Table, DHT) 的實作
  • 節點在邏輯上被組織成一個環狀結構
  • 每個節點都有一個m-bit identifier。
  • 每個資料項目會經過雜湊運算,得到一個 m 位元的鍵值(key)。
  • 此環狀結構會透過一些「捷徑連結(shortcut links)」延伸到其他節點,以加速查詢。
參考
COS 418/518: Distributed Systems Lecture 8-Distributed Hash Tables & Chord(Wyatt Lloyd)
Chord: A Scalable Peer-to-peer Lookup Protocol for Internet Applications
Unstructured P2P
  • 沒有明顯的 overlay topology 架構,每個節點維護一個臨時的鄰居清單。
  • 由此形成的覆蓋網路類似於一個隨機圖,邊 𝑢 ,  𝑣 的存在僅以某個機率 𝑃[𝑢,𝑣] 決定。
搜尋方式
洪泛(Flooding)
  • 發出請求的節點 𝑢 將對資料 𝑑 的請求傳送給所有鄰居。
  • 若接收節點已經看過該請求,則忽略。否則,節點 𝑣 會在本地搜尋資料 𝑑,並遞迴地將請求轉發。
  • 搜尋可由存活時間(Time-To-Live, TTL) 限制,即最大跳數。
隨機漫步(Random walk)
  • 發出請求的節點 𝑢 將對資料 𝑑 的請求傳送給隨機選擇的一個鄰居 𝑣。
  • 如果 𝑣 沒有資料 𝑑,它會再將請求轉發給另一個隨機選擇的鄰居,如此持續下去。
階層式 P2P(Hierarchically organized P2P)
  • 內容傳遞網路(Content Delivery Network, CDN): 讓 Web 用戶端能夠就近存取頁面,從而加快存取速度。
  • 超級節點(Super peers):負責維護索引,或扮演仲介(broker)的角色。
  • 弱節點(Weak peers):以客戶端的形式連接到超級節點。
階層式 P2P屬於對傳統「完全對等」P2P 的改進。
雖然純 P2P 架構強調「節點平等」,但在實務上,引入部分集中化的角色(如索引伺服器或仲介),能顯著改善效能與資源管理效率。
  • 在非結構化 P2P 系統中進行搜尋時,引入索引伺服器(index servers) 可以提升效能。
  • 在決定資料應該存放在哪裡時,透過 仲介(brokers) 通常能更有效率地完成。
邊緣伺服器架構(Edge-server architecture)
這是一種部署在網際網路上的系統架構,伺服器被放置在網路的邊緣位置,即企業網路與真正的網際網路之間的邊界。Ex:家用使用者透過 ISP 連接到網際網路(這被視為位於網際網路的邊緣)。在網路邊緣增加伺服器,可以協助進行運算與儲存,並優化內容與應用程式的分發。
Ref:
https://chaerim-kim.github.io/distributed%20systems/DS-3/
https://www.cnblogs.com/yan2015/p/4927875.html
https://www.cse.lehigh.edu/~chuah/courses/cse497/p2p_lecture2.1.pdf
https://www.cse.lehigh.edu/~chuah/courses/cse497/p2p_lecture3.1.pdf
https://hackmd.io/@leviliangtw/HkFDs3hCP#Week-09---Peer-to-Peer-Systems

留言

這個網誌中的熱門文章

何謂淨重(Net Weight)、皮重(Tare Weight)與毛重(Gross Weight)

(2021年度)駕訓學科筆試準備題庫歸納分析_法規是非題

外貿Payment Term 付款條件(方式)常見的英文縮寫與定義