權衡取捨第 19 頁,共 40 頁約 2 分鐘
可用性模式
關於可用性有兩種模式:容錯轉移 和 複寫。
容錯轉移
主動到備用切換模式(AP Mode)
在這個模式下,heartbeat 訊號會在主動和備用的機器中發送,當 heartbeat 中斷時,備用的機器就會切換為主動機器的 IP 位置接替服務。
當機的時間取決於備用的機器是在「熱」待機狀態還是「冷」待機狀態。只有處於主動的機器會處理使用者來的流量。
這個模式的切換也被稱為主從的切換模式。
雙主動切換模式(AA Mode)
在此模式下,兩台伺服器都會負責處理流量,流量會在他們之間進行分散負載。
如果是外部網路的伺服器,DNS 需要知道兩台機器的 IP 位置,如果是內部網路的伺服器,應用程式邏輯需要知道這兩台機器。
雙主動切換模式也被稱為 master-master 切換。
缺點:容錯轉移
- 容錯轉移會需要增加額外的硬體與複雜度。
- 如果在新寫入的資料被複製到備用的機器前系統就發生故障,那有可能會遺失資料。
複寫機制
主動到備用複寫與雙主動複寫
這一個主題進一步討論了 資料庫 部分:
Availability in numbers
本節尚未翻譯,因此顯示英文原文。
Availability is often quantified by uptime (or downtime) as a percentage of time the service is available. Availability is generally measured in number of 9s--a service with 99.99% availability is described as having four 9s.
99.9% availability - three 9s
| Duration | Acceptable downtime |
|---|---|
| Downtime per year | 8h 45min 57s |
| Downtime per month | 43m 49.7s |
| Downtime per week | 10m 4.8s |
| Downtime per day | 1m 26.4s |
99.99% availability - four 9s
| Duration | Acceptable downtime |
|---|---|
| Downtime per year | 52min 35.7s |
| Downtime per month | 4m 23s |
| Downtime per week | 1m 5s |
| Downtime per day | 8.6s |
Availability in parallel vs in sequence
If a service consists of multiple components prone to failure, the service's overall availability depends on whether the components are in sequence or in parallel.
In sequence
Overall availability decreases when two components with availability < 100% are in sequence:
Availability (Total) = Availability (Foo) * Availability (Bar)If both Foo and Bar each had 99.9% availability, their total availability in sequence would be 99.8%.
In parallel
Overall availability increases when two components with availability < 100% are in parallel:
Availability (Total) = 1 - (1 - Availability (Foo)) * (1 - Availability (Bar))If both Foo and Bar each had 99.9% availability, their total availability in parallel would be 99.9999%.