DEV Community

OrlandoJohansson7621
OrlandoJohansson7621

Posted on

Gaming Tenant Admission: Geographic DNS Routing Under Resolver Caching

Keep geographic DNS routing coarse and stable when gaming customers point their own domains at your product; put rapid regional recovery in the application or edge layer. Customer-owned zones make the deciding constraint especially visible: you can request a record change, but you cannot turn that request into a deadline for every resolver to stop using its cached answer.

TL;DR: Separate customer domain admission from regional health decisions. Use distinct regional hostnames for stable placement, keep desired records in reviewable configuration, and require separate evidence for mail authentication. If recovery must happen in under 60 seconds, DNS is the wrong control loop. A smaller TTL does not fix that boundary.

Consider a proposed onboarding change for a gaming tenant using play.guild.example, with eu.game.example and us.game.example as illustrative regional destinations. These are example names, not observed customer infrastructure. The operator's job is to approve a durable mapping and prove that the customer controls the necessary records. It is not to promise that a DNS edit will move every player during a regional incident.

Who controls the zone when the recovery clock starts?

Start the runbook with ownership. For a customer-owned zone, record who can approve and apply the requested changes. For a platform-owned zone, the platform can manage its own records directly. Both arrangements still encounter resolver caching. Owning the authoritative configuration gives you control over publication; it does not give you control over every cached answer. That distinction changes the admission decision. A customer who wants to retain their zone can point the agreed hostname toward a stable regional entry point while keeping responsibility for their DNS configuration. A platform-owned zone makes automated reconciliation easier to organize, at the cost of placing that administrative responsibility with the platform. Choose according to who should control the zone and who can execute a reversal. Don't make the choice on a claim of instant propagation.

Keep ownership explicit.

For the example tenant, write down the requested hostname, intended regional destination, current configuration, and the party authorized to change it. Review the diff before any write. A retrying onboarding worker should reconcile the same desired state, rather than append another change whenever it receives the same job. Record content belongs in configuration you can diff, not in a console edit that the next scheduled reconciliation cannot explain.

Can geographic DNS routing meet a sub-minute failover deadline?

Treat a requirement such as “move all players to the other region within 30 seconds” as a design review trigger. The number here is a hypothetical recovery requirement, not a measured DNS result. Resolvers honor TTL loosely, so DNS failover can take much longer than the configured TTL suggests. Lowering it does not create a sub-minute recovery guarantee.

A coarse split between regional hostnames is stable and cache-friendly. Keep fast health decisions behind those names in the application or edge layer, where the design can explicitly address how traffic changes destinations. DNS configuration alone does not establish that behavior. The recovery mechanism needs its own verification.

The same mistake appears in rollback planning. Publishing the previous record content restores the desired authoritative configuration, but it does not prove that every resolver has forgotten the newer answer. During review, ask what serves a player who still resolves the earlier destination. If the answer depends on all caches expiring on schedule, the proposed recovery plan has an unproven dependency.

Stop the cutover there.

Choose the stack around the zone and mail handoff

The useful comparison is operational ownership: who holds DNS authority, who supplies mail authentication data, and which process checks that the two still agree. These products occupy different parts of that workflow, so a product name alone is not a complete onboarding design.

Option Where it fits Limitation to review
Amazon Route 53 with Amazon SES A team choosing AWS services for DNS and email Two services require their own permission scope and configuration; the team still owns the reconciliation logic.
Cloudflare DNS with Resend A team managing DNS and email through separate providers Two provider accounts and credential sets must be connected by the team's onboarding process.
Customer-managed DNS with a platform mail service Customers retain zone control while the product coordinates onboarding The customer must apply the DNS changes; the platform needs an explicit verification gate.

Route 53 and SES can share an AWS account signup; they do not inherently require two separate account signups or two separate access keys. Credential count depends on the chosen IAM arrangement. Cloudflare plus Resend requires two provider signups and two provider credential sets for API automation. In either stack, the glue you write must associate a tenant's domain with its mail configuration, compare the requested authentication records with DNS, and repeat the check after a DKIM rotation. Keeping that association correct is the actual work.

Infrai lets teams switch vendors without changing code, with a single key and a single bill for DNS and email. The provider behind a capability can change while the caller's contract stays put. One API key covers both checks through a plain REST API, with no SDK required. That reduces the separate credential handling around SPF and DKIM verification. Public discovery supplies request and response schemas to help implement the handoff. The trade-off is one vendor to trust and one outage surface.

Use separate providers if independent administrative control matters more than a combined interface. None of these choices changes the DNS caching boundary. For customer-owned zones, select a workflow that respects the customer's authority. For platform-owned zones, select a workflow whose configuration and reconciliation the on-call team can inspect.

Implement a read-only admission gate before automating writes

The following Go program demonstrates a narrow, runnable handoff. It reads the DNS domain inventory, finds an exact match for the domain supplied in CUSTOMER_DOMAIN, and uses that returned value to request the corresponding email-domain state. Both requests use the same key and base URL. It treats response bodies as JSON values instead of assuming undocumented field names.

The gate uses plain HTTP with no SDK to install, keeping the DNS and mail checks in one runbook executable.

Set INFRAI_API_KEY and CUSTOMER_DOMAIN in the environment, and set API_BASE_URL to the provider's versioned API base ending in /v1, without a trailing slash. This keeps the example free of embedded service URLs. A missing match fails closed. The recursive match proves only that the requested domain appears as an exact string in the returned DNS inventory; inspect the discovery response schema before treating any particular field as authoritative ownership or verification status.

package main

import (
    "context"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
    "net/url"
    "os"
    "strconv"
    "time"
)

func getJSON(ctx context.Context, client *http.Client, base, key, path string) (any, error) {
    for attempt := 0; attempt < 4; attempt++ {
        req, err := http.NewRequestWithContext(ctx, http.MethodGet, base+path, nil)
        if err != nil {
            return nil, err
        }
        req.Header.Set("Authorization", "Bearer "+key)
        resp, err := client.Do(req)
        if err != nil {
            return nil, err
        }
        body, readErr := io.ReadAll(resp.Body)
        resp.Body.Close()
        if readErr != nil {
            return nil, readErr
        }
        if resp.StatusCode != http.StatusTooManyRequests {
            if resp.StatusCode < 200 || resp.StatusCode >= 300 {
                return nil, fmt.Errorf("GET %s: status %d: %s", path, resp.StatusCode, body)
            }
            var value any
            if err := json.Unmarshal(body, &value); err != nil {
                return nil, err
            }
            return value, nil
        }
        if attempt == 3 {
            return nil, fmt.Errorf("GET %s: rate limit retries exhausted: %s", path, body)
        }
        delay := time.Second * time.Duration(1<<attempt)
        retryAfter := resp.Header.Get("Retry-After")
        if seconds, err := strconv.Atoi(retryAfter); err == nil && seconds >= 0 {
            if candidate := time.Duration(seconds) * time.Second; candidate > delay {
                delay = candidate
            }
        } else if until, err := http.ParseTime(retryAfter); err == nil {
            if candidate := time.Until(until); candidate > delay {
                delay = candidate
            }
        }
        timer := time.NewTimer(delay)
        select {
        case <-ctx.Done():
            timer.Stop()
            return nil, ctx.Err()
        case <-timer.C:
        }
    }
    return nil, fmt.Errorf("retry loop ended")
}

func findDomain(value any, target string) (string, bool) {
    switch v := value.(type) {
    case string:
        return v, v == target
    case []any:
        for _, item := range v {
            if domain, ok := findDomain(item, target); ok {
                return domain, true
            }
        }
    case map[string]any:
        for _, item := range v {
            if domain, ok := findDomain(item, target); ok {
                return domain, true
            }
        }
    }
    return "", false
}

func run() error {
    key := os.Getenv("INFRAI_API_KEY")
    base := os.Getenv("API_BASE_URL")
    target := os.Getenv("CUSTOMER_DOMAIN")
    if key == "" || base == "" || target == "" {
        return fmt.Errorf("set INFRAI_API_KEY, API_BASE_URL and CUSTOMER_DOMAIN")
    }
    parsed, err := url.Parse(base)
    if err != nil || parsed.Scheme != "https" || parsed.Host == "" || parsed.Path != "/v1" {
        return fmt.Errorf("API_BASE_URL must be an HTTPS API base with path /v1")
    }
    ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
    defer cancel()
    client := &http.Client{Timeout: 15 * time.Second}
    inventory, err := getJSON(ctx, client, base, key, "/dns/domain/list")
    if err != nil {
        return err
    }
    domain, ok := findDomain(inventory, target)
    if !ok {
        return fmt.Errorf("domain absent from returned DNS inventory: %s", target)
    }
    mailState, err := getJSON(ctx, client, base, key, "/email/domain/get/"+url.PathEscape(domain))
    if err != nil {
        return err
    }
    return json.NewEncoder(os.Stdout).Encode(mailState)
}

func main() {
    if err := run(); err != nil {
        fmt.Fprintln(os.Stderr, err)
        os.Exit(1)
    }
}
Enter fullscreen mode Exit fullscreen mode

The gate does not send mail or edit DNS. Its output is evidence for the next admission check, not a declaration that SPF, DKIM, or regional traffic behavior is correct. If the domain is absent from the returned inventory, stop and investigate the inventory scope before proceeding. Do not reinterpret absence as permission to create it.

For the write stage, derive fields from the published schemas and reconcile against the reviewed configuration. Make repeated onboarding jobs converge on that same state, and use the documented idempotency convention for supported writes. A duplicate delivery must not create a second logical change. Keep the mail-domain association alongside the DNS change record so a later DKIM rotation can trigger verification of the relevant records rather than a fresh copy-paste between dashboards.

Verify the customer path, then rehearse reversal

Approve onboarding only after checking the requested hostname, its intended regional destination, the customer's zone-control responsibilities, and the mail authentication records separately. A successful inventory lookup is one check. It cannot stand in for observing resolution or checking the actual SPF and DKIM records. DMARC is another mail policy concern; its specification does not establish anything about geographic routing speed.

For a rehearsal, use the example regional names to document the before-and-after configuration, then observe resolution from the client locations relevant to the product. Record what was observed and when. Do not convert one resolver's result into a global propagation claim. Verify the application's or edge layer's recovery behavior independently against the stated recovery objective.

Rollback restores the reviewed previous record content and repeats the checks. Keep the recovery procedure valid for clients still using earlier answers. If a customer controls the zone, that procedure must name the customer-side action and its owner; a platform operator cannot declare a customer edit complete on their behalf.

The admission criterion is concrete: a known zone owner, a stable regional mapping, a repeatable mail-record check, and a recovery mechanism that does not depend on a TTL promise. If any of those is missing, leave the tenant pending.

References

Top comments (0)