
Previous …
上一次,我們主要在講 Primary-Backup 裡面的架構,這次我們要討論 client 端的觀點。
In the last time, we mainly discuss the architecture of primary-backup. This time we are going to talk about the perspective of client.
Client …
1.
和 primary 溝通。
Communicate with primary.
2.
需要知道 primary 的位置。
Need to know the address of primary.

How does client know primary …
透過 view service,得知 primary 的地址。
Know the address of primary through view service.
View Service …
1.
知道目前 primary-backup 的關係,我們稱為 view。
Save the current membership of primary-backup and it is called view.
2.
當 primary 或者 backup 有變動或這失敗時,view 會改變。
View will change if there is changes or failures of primary or backup.
3.
會定期發送訊息探測 primary 跟 backup 的狀態。
Sends messages periodically to detect failures of primary and backup.

Process of changing view …
1.
View Service 會告訴所有節點 View 的變化。
View service announces view change to all nodes.
2.
上次有提到,Primary 要收到 Backup 回傳的 ACK 訊息,確認 Backup 已經同步。
In the last time, we mentioned that primary will receive ACK message from backup to ensure the syncing.
3.
確認 Backup 同步後,Primary 必須發送 ACK 訊息,代表承認新的 View。
After ensuring syncing with backup, primary must send ACK message to acknowledge the new view.
Questions …
1. What will happen if primary failed when view changes?
如果 View 變更時,primary 失敗,則整個程序會卡住。
The process of changing view will be stucked if primary failed at the same time.
2.How to scale view service?
客戶端可以暫存 View。
Client can cache view.
3. How does the client know the cached view is valid or not?
如果客戶端訪問 primary 沒有回應或者得到錯誤訊息時,客戶端會重新去訪問 View Service 並且將暫存的 View 視為無效.
If there is no response or error message from primary, client will send new request to view service and invalidate the cached view.
-MsHe