- Control which datacenters are considered for a service lookup.
- Prefer endpoints with the lowest round-trip time (RTT).
- Implement hybrid fallback rules (latency preference plus deterministic fallbacks).
- Make multi-cloud and multi-datacenter discovery predictable and resilient.
- Static failover policy — specify an ordered list of datacenters to try.
- Dynamic failover policy — prefer the N nearest datacenters by latency (NearestN).
- Hybrid failover policy — combine nearest-N latency selection with an ordered static fallback list.
web-app, try dc2 first, then dc3 as deterministic fallbacks.
Example: dynamic failover policy (nearest N)
dc2, then dc3.
Choosing between policies
- Static failover: simple, deterministic, good for small or stable environments with fixed datacenters.
- Dynamic failover: useful when datacenter availability changes frequently (for example, ephemeral environments) and you want low-latency sources prioritized.
- Hybrid failover: combine latency preference with deterministic fallback behavior for predictable resilience.
dc2) is included in the nearest-N selection, it won’t be re-queried again during the static fallback list. The static fallback excludes any datacenters already attempted as part of the nearest-N selection.
Use static failover for small, stable deployments. Choose dynamic or hybrid failover when datacenters are ephemeral or when you want latency-aware selection with deterministic fallbacks.
Links and references
- Consul Prepared Queries (reference)
- Service discovery patterns and best practices
- Multi-datacenter design considerations
- DNS is simple and broadly supported but not sufficient for advanced multi-datacenter routing.
- Prepared queries add dynamic selection and richer discovery behavior inside a region or datacenter.
- Prepared queries with failover policies are the ideal solution for multi-cloud and multi-datacenter applications where you need latency-awareness plus controlled fallbacks.
