Hướng dẫn

Multi-region failover with a WireGuard mesh

Nâng cao40 phút đọcCập nhật 8 tháng 7, 2026
Câu trả lời ngắn

Ba phiên bản ở ba quốc gia, kết nối mạng lưới qua WireGuard, với ứng dụng chỉ gắn vào mạng lưới và một bản ghi DNS được kiểm tra sức khỏe phía trước, mang lại khả năng chịu lỗi thực sự với chi phí dưới 110 đô la mỗi tháng. Ràng buộc thiết kế là nhân bản cơ sở dữ liệu: đồng bộ trong khu vực, không đồng bộ xuyên khu vực.

01 Choose three independent failure domains

Different countries, ideally different transit mixes. Amsterdam, Ashburn and Singapore is the classic triangle. Three is the minimum for quorum — two gives you a split-brain problem rather than redundancy.

02 Build the mesh

Each node gets a stable private address. Every node peers with every other node; with three nodes that is three tunnels.

# node A — /etc/wireguard/mesh.conf
[Interface]
Address = 10.10.0.1/24
ListenPort = 51821
PrivateKey = <A private>

[Peer]                       # node B
PublicKey = <B public>
Endpoint = b.example.net:51821
AllowedIPs = 10.10.0.2/32
PersistentKeepalive = 25

[Peer]                       # node C
PublicKey = <C public>
Endpoint = c.example.net:51821
AllowedIPs = 10.10.0.3/32
PersistentKeepalive = 25

03 Bind services to the mesh only

The database, the cache and the internal API should listen on 10.10.0.x, never on the public address. This removes an entire class of exposure without a single firewall rule.

04 Nhân bản cơ sở dữ liệu một cách phù hợp

Synchronous replication across regions is impractical — a 160 ms round trip becomes the floor for every write. Use asynchronous replication across regions and know your recovery point objective.

05 Kiểm tra sức khỏe ở lớp DNS

Short TTLs plus health-checked failover records, or anycast if your regions support it. Then run a failure drill: kill a region deliberately, on a weekday, while you are watching.

Câu hỏi thường gặp

Why not just buy a bigger server?

Một máy chủ lớn hơn có cùng số điểm lỗi như máy chủ nhỏ: một. Tính khả dụng đến từ tính độc lập, không phải từ dung lượng.

How far apart can etcd or Postgres synchronous replicas be?

Giữ các bản sao đồng bộ (synchronous replicas) cách nhau trong khoảng 100 ms. Vượt quá mức đó, độ trễ ghi (write latency) trở thành chi phí chiếm ưu thế trong mọi giao dịch.