DNS for APIs

Choose a TTL and routing policy for the API hostname. Check new resolutions separately from clients that reuse open connections or cached addresses.

API endpoint cutover
Public name
api.example.com.
Previous A record
192.0.2.10
Replacement A record
192.0.2.20

Steer new API connections during an endpoint change

Put api.example.com on Cloud DNS. Steer with GeoDNS or weights, health-check every pool, and use low TTLs so canaries and failovers work.

Canary API pools in DNS

Weighted answers send a fraction of resolvers to a new API stack.

Failed API regions disappear

Health checks remove non-responsive endpoints from eligible answers.

Regional API entry points

GeoDNS sends resolvers toward the nearest live API hostname or address.

Configuration

Cloud DNS overview
  1. Host the API zone or record set

    api, auth and webhook hostnames.

  2. Publish more than one pool

    Even if 100% of weights start on a single pool.

  3. Attach health checks

    Probe the API the way clients use it, over HTTPS.

  4. Keep TTLs short on api.*

    Clients will cache. Give yourself a way to move them.

Operational outcomes

  • API DNS can canary and fail over
  • Regional entry points are explicit
  • Unhealthy pools leave the rotation
  • Authority is Anycast, not a registrar default

Frequently asked questions

Should the API sit behind Cloud CDN?

Cacheable GET APIs often should. See CDN for APIs. Cloud DNS still steers the hostname.

What about gRPC or HTTP/2-only APIs?

DNS is agnostic to the application protocol. Health checks should match how you determine liveness.

Can I split EU and US tenants in DNS?

GeoDNS can steer, but tenancy is an application concern. Do not rely on DNS alone for residency.

Do SDKs honour TTL?

Most OS resolvers do, with clamping. Document expected TTL behaviour for long-lived mobile clients.