Skip to content

Routing Modes — Regional vs Global trong Cloud Router

Tại sao quan trọng trong production

Routing mode của VPC là cấu hình thoạt trông đơn giản nhưng có hệ quả sâu sắc đến cách routes từ hybrid connectivity (Cloud VPN, Interconnect) propagate trong toàn bộ VPC. Sai routing mode dẫn đến asymmetric routing — traffic đi qua một region nhưng về qua region khác — gây break stateful firewall và khó debug.


Internal Model — Cơ Chế Propagation Routes

Regional Mode (Mặc định)

Trong regional routing mode, dynamic routes học được từ BGP peer chỉ có hiệu lực trong cùng region với Cloud Router:

  • Cloud Router ở us-central1 học routes từ on-premises qua HA VPN.
  • Routes đó chỉ được install vào route table của VMs trong us-central1.
  • VMs ở europe-west1 trong cùng VPC không thấy routes on-premises này.

Đây là thiết kế intentional: region isolation cho dynamic routes ngăn misconfigured on-premises routes ảnh hưởng đến toàn bộ VPC.

Khi nào regional mode phù hợp: Mỗi region có Cloud Router riêng và hybrid connectivity riêng. Traffic không cần cross-region để reach on-premises.

Global Mode

Trong global routing mode, best-path dynamic routes từ tất cả Cloud Routers trong VPC được propagate đến tất cả regions:

  • Cloud Router ở us-central1 học routes từ on-premises.
  • Routes này available cho VMs ở tất cả regions trong VPC.
  • VM ở europe-west1 gửi traffic đến on-premises IP: traffic traverse GCP backbone sang us-central1, rồi exit qua VPN/Interconnect.

Cơ chế propagation: GCP control plane không chạy BGP giữa các Cloud Routers. Thay vào đó, dynamic route control plane collect "best path" routes từ mỗi Cloud Router và distribute qua internal GCP mechanism. Đây là distribution của kết quả BGP computation, không phải BGP re-distribution.

Inter-region cost penalty: Khi routes propagate cross-region, GCP thêm một implicit cost để ưu tiên local paths. VMs trong region có Cloud Router cục bộ với hybrid connection sẽ prefer local path — ngay cả trong global mode.


Best Path Selection Mode

Cloud Router có hai best path selection mode, ảnh hưởng đến cách chọn giữa multiple paths đến cùng destination:

Legacy Mode

Dùng thuật toán đơn giản: chọn theo priority (route priority). Không consider đầy đủ BGP path attributes theo RFC.

Standard Mode (khuyến nghị)

Dùng đầy đủ BGP decision process theo RFC 4271:

  1. Highest LOCAL_PREF
  2. Shortest AS Path
  3. Lowest ORIGIN code
  4. Lowest MED
  5. eBGP over iBGP
  6. Lowest BGP router ID

Standard mode cho phép MED-based traffic engineering hoạt động đúng — critical cho active-passive failover với Interconnect và HA VPN.


Constraints & Trade-offs

Asymmetric Routing Risk trong Global Mode

Khi global mode bật và on-premises quảng bá routes đến Cloud Router ở nhiều regions, traffic asymmetry có thể xảy ra:

VM (europe-west1) → traffic → on-premises (qua us-central1 Interconnect)
On-premises → response → Cloud Router (europe-west1) → VM

Với stateful firewall on-premises, asymmetric routing break firewall session tracking.

Mitigation: Dùng AS Path prepending hoặc MED manipulation để ensure consistent path, hoặc dùng regional mode để traffic flow symmetric.

VPC Peering với Global Mode

Khi hai VPC peering với nhau và VPC source dùng global mode:

  • VPC A (global mode) export custom dynamic routes qua peering → VPC B nhận routes.
  • Routing mode của exporting VPC quyết định routes nào được exported.
  • export-custom-routesimport-custom-routes phải được bật trên cả hai sides.

Khi Nào Dùng Mỗi Mode

ScenarioMode khuyến nghị
Mỗi region có hybrid connection riêngRegional
Chỉ một region có hybrid connection, VMs ở nhiều regionsGlobal
Muốn traffic isolation giữa các regionsRegional
Multi-region workloads cần reach cùng on-premisesGlobal
Có stateful firewall on-premises nhạy cảm với asymmetricRegional

GCP-native Implementation Guidance

bash
# Chuyển sang global mode
gcloud compute networks update my-vpc \
  --bgp-routing-mode=GLOBAL

# Chuyển về regional mode
gcloud compute networks update my-vpc \
  --bgp-routing-mode=REGIONAL

# Kiểm tra routing mode hiện tại
gcloud compute networks describe my-vpc \
  --format='value(routingConfig.routingMode)'

Thay đổi routing mode áp dụng ngay và có thể gây traffic disruption nếu routes bị propagate hoặc withdrawn. Thực hiện trong maintenance window.


References