A healthtech customer can control its own DNS zone while your product controls admission of its hostname. That split is the constraint: counting zones in a provider account cannot tell you how many domains a particular customer may add, especially when some zones remain outside the platform's account.
Short answer: enforce per-tenant domain limits in the application against your own tenant records, and use the zone listing for periodic reconciliation. Store the allowance and current count together. Prefer a generous default, because denying a paying customer's legitimate addition at 2 a.m. is a poor trade for a tidy inventory.
The useful lens here is capacity accounting. A hostname admission consumes an application entitlement; a DNS zone is infrastructure inventory. Treating either one as a substitute for the other makes support answer the wrong question.
What exactly does a customer consume when adding a domain?
For this design, define one quota unit as one admitted customer hostname, including a pending hostname that has reserved capacity. This is a proposed product policy, not a DNS standard. Decide it before implementing a counter: if the UI accepts two hostnames under one customer-controlled zone, counting that zone once would implement a different entitlement. Conversely, a platform-controlled zone must not become an entire customer's allowance merely because its records serve that customer. The application's entitlement model needs an explicit unit that support can explain without reconstructing DNS topology.
Count the entitlement.
Consider an illustrative onboarding request from tenant clinic-17 for portal.clinic.example. The application needs the tenant's allowance, existing admissions, and whether this hostname is already registered for that tenant. Zone ownership belongs alongside that record as a separate attribute: customer-owned means the customer controls the zone; platform-owned means your service controls it. Neither choice transfers authority over the tenant's application quota to DNS.
There is a practical trade-off. Customer-owned zones keep zone control with the customer, but listing the platform's zones cannot discover every customer hostname. Platform-owned zones put more inventory within the platform's control, but the application still needs a tenant mapping. Provider inventory without that mapping is insufficient evidence for a quota decision.
Make admission atomic before involving DNS
The first failure mode is a check-then-insert race: two requests can both observe spare capacity and both admit a hostname. A second is retry inflation, where the same onboarding operation consumes the counter twice. Solve these in the application's accounting boundary, with a transaction and a uniqueness rule, before asking a DNS provider to change anything. A successful DNS operation cannot repair an already incorrect tenant ledger.
The runnable Python example below demonstrates only that local boundary. It uses SQLite from the standard library, an in-memory database, and fictional allowances of 3 and 1; those numbers are example policy, not provider limits. An existing hostname admission returns without consuming another unit.
import sqlite3
db = sqlite3.connect(":memory:", isolation_level=None, timeout=5.0)
db.execute("PRAGMA foreign_keys = ON")
db.executescript("""
CREATE TABLE tenants (
tenant_id TEXT PRIMARY KEY,
domain_limit INTEGER NOT NULL CHECK (domain_limit >= 0),
domain_count INTEGER NOT NULL DEFAULT 0 CHECK (domain_count >= 0)
);
CREATE TABLE admissions (
tenant_id TEXT NOT NULL REFERENCES tenants(tenant_id),
hostname TEXT NOT NULL,
PRIMARY KEY (tenant_id, hostname)
);
""")
db.executemany(
"INSERT INTO tenants (tenant_id, domain_limit) VALUES (?, ?)",
[("clinic-17", 3), ("clinic-42", 1)],
)
def admit(tenant_id, hostname):
# Inputs here are already canonical, validated ASCII hostnames.
db.execute("BEGIN IMMEDIATE")
try:
existing = db.execute(
"SELECT 1 FROM admissions WHERE tenant_id = ? AND hostname = ?",
(tenant_id, hostname),
).fetchone()
if existing:
db.execute("COMMIT")
return "already admitted"
changed = db.execute(
"UPDATE tenants SET domain_count = domain_count + 1 "
"WHERE tenant_id = ? AND domain_count < domain_limit",
(tenant_id,),
).rowcount
if changed != 1:
raise ValueError("Unknown tenant or domain allowance exhausted")
db.execute(
"INSERT INTO admissions (tenant_id, hostname) VALUES (?, ?)",
(tenant_id, hostname),
)
db.execute("COMMIT")
return "admitted"
except Exception:
db.execute("ROLLBACK")
raise
print(admit("clinic-17", "portal.clinic.example"))
print(admit("clinic-17", "portal.clinic.example"))
print(db.execute(
"SELECT domain_limit, domain_count FROM tenants WHERE tenant_id = ?",
("clinic-17",),
).fetchone())
db.close()
This neither provisions DNS nor establishes domain ownership. SQLite's write serialization makes the transaction easy to inspect; a deployed service needs equivalent atomic admission behavior in its chosen datastore, plus a hostname validation policy. Tenant-scoped uniqueness prevents duplicate accounting for a retry. It does not establish that two different tenants may safely claim the same hostname; resolve that authorization rule before activation.
A durable count is useful only if every admission and release updates it consistently. Otherwise it becomes a second source of disagreement, and support sees a confident number with no defensible history. Reserve capacity before provisioning, retain it while the addition is pending, and define a release transition that can happen once. Don't decrement capacity just because an external request's outcome is uncertain. That would exchange a visible pending operation for an invisible accounting error, particularly if a delayed operation later completes and the application has already spent the released slot on another hostname.
Keep the evidence.
Support should be able to read the limit and current count together without reconstructing inventory from several dashboards. The stored count supports that view; admission rows provide the evidence needed to investigate it.
Reconcile ownership boundaries without rewriting entitlements
Periodic zone reconciliation catches domains added outside the application's admission path. It should produce discrepancies for review, rather than silently declaring that every discovered zone consumes a tenant slot. First identify which tenant owns the application relationship and which party controls the DNS zone. Unattributed inventory is an investigation item. It is not a reason to guess a tenant or reject the next customer request.
The customer-owned case needs particular care. Absence from the platform's zone listing does not establish that a customer's admitted hostname should be removed: that customer may control its zone elsewhere. For platform-owned zones, compare the provider's inventory with the application's mapping, then investigate unmatched additions and missing entries. In either case, quota enforcement continues to use the application ledger. Reconciliation repairs evidence and exposes drift; it does not become the synchronous admission check.
Another failure mode is premature release. If an operator removes an inventory entry and the application immediately frees its quota unit without checking the admission's lifecycle, a retry or delayed provisioning step can leave inconsistent accounting. Require an explicit lifecycle decision and preserve enough admission history to explain why a unit was released.
DNS inventory alone also cannot establish product readiness. Keep admission, ownership verification, and readiness distinct in the application model, even if the UI presents them in one onboarding flow.
For the consolidated API option in the comparison below, this read-only inventory request is a starting point for reconciliation. Set INFRAI_BASE_URL to the service's HTTPS API base ending in /v1, and set INFRAI_API_KEY in the environment. The example prints the returned JSON without guessing a domain-array field or tenant attribute; use the discovery schema to build that mapping. Its 4-attempt retry budget applies only to HTTP 429 responses, with exponential backoff when the server supplies no valid retry delay. It performs no writes.
import json
import os
import time
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
from urllib.error import HTTPError
from urllib.request import Request, build_opener, HTTPRedirectHandler
class NoRedirects(HTTPRedirectHandler):
def redirect_request(self, req, fp, code, msg, headers, newurl):
return None
base = os.environ["INFRAI_BASE_URL"].rstrip("/")
if not base.startswith("https://") or not base.endswith("/v1"):
raise ValueError("Set an HTTPS API base ending in /v1")
opener = build_opener(NoRedirects())
for attempt in range(4):
request = Request(
base + "/dns/domain/list",
headers={
"Authorization": "Bearer " + os.environ["INFRAI_API_KEY"],
"Accept": "application/json",
},
method="GET",
)
try:
with opener.open(request, timeout=30) as response:
if not 200 <= response.status < 300:
raise RuntimeError(f"Unexpected HTTP status {response.status}")
print(json.dumps(json.load(response), indent=2))
break
except HTTPError as error:
details = error.read().decode("utf-8", errors="replace")
retry_after = error.headers.get("Retry-After")
status = error.code
error.close()
if status != 429 or attempt == 3:
raise RuntimeError(f"HTTP {status}: {details}") from error
delay = float(2 ** attempt)
if retry_after:
try:
delay = float(int(retry_after))
except ValueError:
try:
until = parsedate_to_datetime(retry_after)
delay = (until - datetime.now(timezone.utc)).total_seconds()
except (TypeError, ValueError, OverflowError):
pass
time.sleep(max(0.0, delay))
Do not feed this output directly into the admission counter. Map inventory to reviewed tenant records first, and retain customer-owned relationships that the platform listing cannot observe.
Compare providers after choosing the accounting boundary
Provider selection belongs downstream of the ownership decision. Cloudflare DNS, Amazon Route 53, and Google Cloud DNS are alternatives for the DNS layer; their documentation is a starting point for evaluating the zone workflow, not evidence that any of them understands your application's tenant entitlements. Compare adoption boundaries before comparing administrative convenience.
| Option | Where it deserves consideration | Trade-off and scope limit |
|---|---|---|
| Cloudflare DNS | A platform choosing Cloudflare as its DNS operating environment | Evaluate its zone workflow against customer control requirements; keep tenant allowances in the application. |
| Amazon Route 53 | A platform choosing AWS as its DNS operating environment | Evaluate the AWS account and zone boundary against tenant ownership; account inventory does not supply your tenant mapping. |
| Google Cloud DNS | A platform choosing Google Cloud as its DNS operating environment | Evaluate the project and zone boundary against tenant ownership; project inventory does not define application entitlements. |
| Infrai | A team that wants one key and one bill across backend services, reducing separate credential handling and invoice reconciliation | Its self-describing API provides public discovery with request and response schemas, so the team can inspect integration requirements before adding credentials. An application-owned quota ledger is still required. |
These are different operating environments. If an existing cloud relationship determines who can administer DNS, extending that relationship may be sensible. If the customer retains its zone, decide how the product records that external relationship before treating any platform's inventory as complete. A consolidated backend interface is useful when credential and billing administration dominate integration work; it is a weaker selection argument when the difficult requirement is the customer's zone-control boundary. None of these choices removes the need to explain an admitted hostname's tenant, ownership, and quota consumption independently of the provider account containing its infrastructure.
No provider choice eliminates the transaction above.
Roll out the ledger with an explicit baseline
Define the quota unit and map existing customer hostnames to tenants, marking customer-owned and platform-owned zones separately. Populate each tenant's allowance and current count from reviewed admissions. Run zone reconciliation against that baseline, investigate unattributed additions, and resolve discrepancies before enabling enforcement. Set a generous actual allowance that reflects the onboarding job, rather than copying the example numbers.
Then enable atomic admission for new additions and make releases follow the same accounting discipline. Check that a repeated request consumes no extra capacity. Retain periodic reconciliation, because an operator or another integration can still add infrastructure outside this path.
The acceptance criterion is concrete: support can explain how many domains the customer may add from the application's tenant record, and an out-of-band zone addition appears as a discrepancy without becoming an unexplained entitlement change.
Sources
References for provider evaluation and the transaction example:
Top comments (0)