Panduan

Failover multi-region dengan mesh WireGuard

Lanjutan40 menit bacaDiperbarui 8 Juli 2026
Jawaban singkat

Tiga instans di tiga negara, dihubungkan melalui WireGuard, dengan aplikasi hanya terikat ke mesh dan catatan DNS dengan health-check di depannya, memberikan toleransi kesalahan yang sesungguhnya dengan biaya di bawah $110 per bulan. Kendala desainnya adalah replikasi database: sinkron dalam satu wilayah, asinkron antar wilayah.

01 Pilih tiga domain kegagalan yang independen

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 Bangun 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 Ikat layanan hanya ke mesh

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 Replikasi database dengan tepat

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 Periksa kesehatan di lapisan 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.

Pertanyaan yang sering diajukan

Mengapa tidak membeli server yang lebih besar saja?

Server yang lebih besar memiliki jumlah domain kegagalan yang sama dengan yang kecil: satu. Ketersediaan datang dari independensi, bukan dari kapasitas.

Seberapa jauh replika sinkron etcd atau Postgres bisa berada?

Jaga replika sinkron dalam jarak sekitar 100 ms satu sama lain. Di luar itu, latensi tulis menjadi biaya dominan dari setiap transaksi.