PCI DSS 4.0 provider failover and degradation architecture for enterprise LLM deployment — Reference Architecture
Deployment parameters
Every value below is a parameter you can hold a vendor or an internal team to. Adjectives are not acceptance criteria.
| Deployment vector | Customer-managed VPC, provider model endpoint pinned to region |
|---|---|
| Security standard | PCI DSS 4.0 |
| Applicable regimes | SOC 2 Type II, ISO/IEC 27001:2022, GDPR |
| Latency SLA | p95 ≤ 600ms — interactive surfaces need sub-second; batch jobs do not |
| Integration protocol | REST over HTTPS — the widest compatibility and the easiest audit story |
| Idempotency control | an Idempotency-Key header, honoured for 24h |
| Throughput envelope | ~2k rps per gateway node before connection churn dominates |
| Middleware requirement | policy decision point in front of the model gateway |
| Data classes in scope | PII, commercial-in-confidence data |
| Retention obligation | per the data class retention schedule, enforced automatically |
| Data residency | contracted processing region, asserted on every response |
| Contractual instrument | DPA plus a disclosed subprocessor list |
| Systems of record | SAP, Salesforce, Workday |
| Primary failure mode | a retried POST creating a duplicate record |
The control that resolves this is a Labelled Degradation Ladder, evaluated before the request reaches a model provider rather than audited afterwards. In regulated enterprise the binding constraint is PCI DSS 4.0, and the question it actually asks is is cardholder data in scope, and can you prove it is not. The shape below holds p95 ≤ 600ms over REST over HTTPS, and ships with a standard-library implementation that runs as written.
Why this blocks production
When the primary provider degrades, traffic fails over to a weaker model and the answers keep flowing. Nobody downstream is told the quality changed, so the incident is discovered in complaints.
What PCI DSS 4.0 specifically requires
PCI scope is contagious: any system that stores, processes or transmits cardholder data — or can affect the security of one that does — is in scope. The cheapest control is to keep the model tier out of scope entirely.
The artifact that satisfies it is a segmentation test proving the model tier is out of scope. The way teams most often fail it: a PAN reaching a prompt log, dragging the whole inference tier into PCI scope.
Working implementation — Degradation ladder with circuit breaker and quality floor
Standard-library Python, no external dependencies, runs as written. Executed by the publish gate: if it raises, this page does not ship. Wire it behind REST over HTTPS; the failure mode it guards against is a retried POST creating a duplicate record. The output you hand the assessor is the segmentation test report.
"""Degradation ladder with a circuit breaker and labelled quality tiers.
The failure: a provider degrades, traffic silently fails over to a weaker
model, and nobody downstream knows the answer came from a lower tier. The
control is that degradation is explicit and labelled on the response, so a
consumer can refuse a tier it cannot accept, and that a failing provider is
taken out of rotation rather than retried into the ground.
"""
import time
class ProviderDown(Exception):
pass
class CircuitBreaker:
def __init__(self, threshold: int = 3, cooldown_s: float = 30.0):
self.threshold, self.cooldown_s = threshold, cooldown_s
self.failures, self.opened_at = 0, None
def record_failure(self, now: float) -> None:
self.failures += 1
if self.failures >= self.threshold and self.opened_at is None:
self.opened_at = now
def record_success(self) -> None:
self.failures, self.opened_at = 0, None
def closed(self, now: float) -> bool:
if self.opened_at is None:
return True
if now - self.opened_at >= self.cooldown_s:
self.opened_at, self.failures = None, 0 # half-open: allow a probe
return True
return False
class Tier:
def __init__(self, name: str, quality: int, call):
self.name, self.quality, self.call = name, quality, call
self.breaker = CircuitBreaker()
class DegradationLadder:
"""Tiers in descending quality. The response always names the tier that
produced it; a caller declaring min_quality gets a refusal rather than a
quietly worse answer."""
def __init__(self, tiers: list):
self.tiers = sorted(tiers, key=lambda t: -t.quality)
self.events: list[dict] = []
def complete(self, prompt: str, min_quality: int = 0, now=None) -> dict:
now = now if now is not None else time.monotonic()
attempted = []
for tier in self.tiers:
if tier.quality < min_quality:
continue
if not tier.breaker.closed(now):
attempted.append({"tier": tier.name, "skipped": "circuit open"})
continue
try:
text = tier.call(prompt)
except ProviderDown:
tier.breaker.record_failure(now)
attempted.append({"tier": tier.name, "failed": True})
continue
tier.breaker.record_success()
degraded = tier is not self.tiers[0]
self.events.append({"tier": tier.name, "degraded": degraded})
return {"text": text, "tier": tier.name, "quality": tier.quality,
"degraded": degraded, "attempts": attempted}
raise ProviderDown(
f"no tier at or above quality {min_quality} available: {attempted}")
if __name__ == "__main__":
def primary(p): raise ProviderDown("502 from primary")
def secondary(p): return f"secondary:{p}"
def local(p): return f"local-small:{p}"
ladder = DegradationLadder([
Tier("frontier", 100, primary),
Tier("secondary", 70, secondary),
Tier("local-small", 30, local)])
r = ladder.complete("summarise", now=0.0)
assert r["tier"] == "secondary" and r["degraded"] is True, r
assert r["attempts"][0]["failed"], r
# A caller that cannot accept degradation gets an error, not a worse answer.
strict = DegradationLadder([Tier("frontier", 100, primary),
Tier("local-small", 30, local)])
try:
strict.complete("x", min_quality=90, now=0.0)
raise AssertionError("served below the declared quality floor")
except ProviderDown:
pass
# The breaker opens after repeated failures and stops the retry storm.
t = Tier("flaky", 50, primary)
for i in range(3):
try:
t.call("x")
except ProviderDown:
t.breaker.record_failure(now=float(i))
assert not t.breaker.closed(now=3.0), "breaker should be open"
assert t.breaker.closed(now=40.0), "breaker should half-open after cooldown"
print("Degradation ladder + circuit breaker: OK")
print(f" served tier={r['tier']} degraded={r['degraded']}, "
f"events {len(ladder.events)}")
The PCI DSS 4.0 control, as code
PAN tokenisation and a scope-reduction proof. This is the artifact an assessor asks for under PCI DSS 4.0 specifically — it is not the same control as the one above, and a system that implements one does not thereby implement the other. It executes under the same publish gate.
"""PAN detection with tokenisation, and a scope-reduction proof.
PCI DSS 4.0 scope is everything that stores, processes or transmits account
data, plus anything connected to it. The cheapest compliance move is not better
controls — it is removing systems from scope. A model gateway that never sees a
PAN is out of scope; one that sees it once is in, along with everything it talks
to.
"""
import hashlib
import re
PAN_RE = re.compile(r"\b(?:\d[ -]?){12,18}\d\b")
def luhn_valid(digits: str) -> bool:
total, parity = 0, len(digits) % 2
for i, ch in enumerate(digits):
d = int(ch)
if i % 2 == parity:
d *= 2
if d > 9:
d -= 9
total += d
return total % 10 == 0
class TokenVault:
"""Format-preserving surrogate. The vault is in scope; nothing it feeds is,
provided the surrogate is not reversible outside it."""
def __init__(self, pepper: str):
self._pepper = pepper
self._map: dict[str, str] = {}
def tokenise(self, pan: str) -> str:
digest = hashlib.sha256(f"{self._pepper}:{pan}".encode()).hexdigest()
surrogate = "4" + str(int(digest[:15], 16)).zfill(15)[:15]
self._map[surrogate] = pan
return surrogate
def last_four(self, pan: str) -> str:
return pan[-4:]
class ScopeBoundary:
def __init__(self):
self.systems: dict[str, bool] = {}
self.flows: list[tuple[str, str]] = []
def add(self, system: str, sees_pan: bool) -> None:
self.systems[system] = sees_pan
def flow(self, src: str, dst: str) -> None:
self.flows.append((src, dst))
def in_scope(self) -> set[str]:
scope = {s for s, sees in self.systems.items() if sees}
changed = True
while changed: # connected-to is also in scope
changed = False
for src, dst in self.flows:
if src in scope and dst not in scope:
scope.add(dst); changed = True
elif dst in scope and src not in scope:
scope.add(src); changed = True
return scope
def redact(text: str, vault: TokenVault) -> tuple[str, int]:
found = 0
def _sub(m):
nonlocal found
raw = re.sub(r"[ -]", "", m.group(0))
if not luhn_valid(raw):
return m.group(0)
found += 1
return f"tok_{vault.tokenise(raw)}(last4={vault.last_four(raw)})"
return PAN_RE.sub(_sub, text), found
if __name__ == "__main__":
vault = TokenVault(pepper="hsm-managed")
text = "Charge card 4111 1111 1111 1111 for invoice 9912, ref 1234567890123456"
out, n = redact(text, vault)
assert n >= 1 and "4111 1111 1111 1111" not in out, out
assert "last4=1111" in out, out
# A number that fails Luhn is not a PAN and must not be mangled.
benign, n2 = redact("order 1234 5678 9012 3450 placed", vault)
assert n2 == 0 and "1234 5678 9012 3450" in benign, benign
sb = ScopeBoundary()
sb.add("checkout", True); sb.add("token_vault", True)
sb.add("llm_gateway", False); sb.add("analytics", False)
sb.flow("checkout", "token_vault"); sb.flow("token_vault", "llm_gateway")
scope = sb.in_scope()
assert "llm_gateway" in scope, "connected-to is in scope — that is the point"
clean = ScopeBoundary()
clean.add("checkout", True); clean.add("token_vault", True)
clean.add("llm_gateway", False)
clean.flow("checkout", "token_vault")
assert "llm_gateway" not in clean.in_scope(), clean.in_scope()
print("PCI DSS 4.0 tokenisation + scope reduction: OK")
print(f" PANs tokenised {n}, naive scope {len(scope)} systems, "
f"segmented scope {len(clean.in_scope())} systems")
The blueprint
Labelled Degradation Ladder — the request path, with the decision points that must exist before the first model call:
flowchart LR
REQ[Request + min_quality] --> T1{Tier 1 breaker closed?}
T1 -->|open| T2{Tier 2}
T1 -->|closed| CALL1[Call tier 1]
CALL1 -->|fails| BRK[Record failure<br/>maybe open breaker] --> T2
T2 -->|below min_quality| REFUSE[Refuse: no acceptable tier]
T2 -->|ok| CALL2[Call tier 2] --> LAB[Label response<br/>degraded=true]Modular implementation framework
- Quality-ranked tiers — Explicit integer quality per provider, not an implicit order.
- Circuit breaker — A failing tier leaves rotation instead of being retried into the ground.
- Half-open probe — One probe after cooldown; recovery is tested, not assumed.
- Tier label on response — Every answer names its tier and whether it was degraded.
- Quality floor per caller — A caller declares a minimum; below it is a refusal.
- Degradation events — Each failover recorded — the signal the incident needs.
Risk and control matrix
Each row carries an acceptance parameter rather than an adjective, because "low latency" cannot be signed off. Retention here is bound by per the data class retention schedule, enforced automatically.
| Category | Risk | Control | Acceptance parameter |
|---|---|---|---|
| PCI DSS 4.0 | A PAN in a prompt pulls the inference tier into PCI scope | Tokenise before the model boundary and prove segmentation with a penetration test at least annually | Segmentation test passes; 0 PANs detected in prompt or completion stores by continuous scanning |
| Operational | Silent failover hides a quality drop from consumers | Every response names its tier and carries a degraded flag | 100% of responses labelled; degraded responses counted per hour |
| Operational | Retry storm against an already-failing provider | Circuit breaker opens after a threshold and cools down before a probe | No more than the threshold of calls to a failing tier per cooldown |
| Operational | A caller receives an answer below its acceptable quality | Declared quality floor; below it the ladder refuses rather than serves | 0 responses below a caller's declared floor; refusal raised instead |
| Cost control | Failover to a more expensive tier inflates spend | Tier order is quality-ranked and cost is recorded per tier per hour | Spend per tier visible; failover cost attributable |
| Latency SLA | Serial failover stacks timeouts and breaches the SLO | Per-tier timeout budget; the ladder's total is bounded | Total time bounded by the declared budget, measured at p95 |
| Operational | Recovery is assumed rather than verified | Half-open state admits a single probe before restoring rotation | One probe per cooldown; full restoration only after it succeeds |
| Data privacy | Failover sends data to a provider outside the contracted region | Tiers carry a residency attribute; out-of-region tiers excluded by policy | 0 failovers to a tier outside the contracted processing region |
Control questions before sign-off
- Is the inference tier in PCI scope, and what segmentation test proves it is not?
Cardholder data is tokenised before the model boundary and the segmentation is evidenced by an annual penetration test, so the tier stays out of scope by design. - When the primary provider fails, how does a downstream consumer learn the answer came from a weaker model?
The response names the tier that produced it and carries a degraded flag. A consumer reading the label can treat a degraded answer differently; silent failover is what this design exists to prevent. - What stops a failing provider from being retried thousands of times a minute?
The circuit breaker. After the failure threshold it opens and the tier is skipped entirely until the cooldown elapses, so a failing provider leaves rotation rather than absorbing retries. - Can a caller that requires top-tier quality be served a degraded answer?
No. The caller declares a minimum quality and tiers below it are never attempted — the ladder raises instead of serving, which is the correct outcome when no acceptable tier exists. - How do you know a recovered provider is actually healthy before restoring full traffic?
The breaker goes half-open after cooldown and admits a single probe. Full rotation is restored only after that probe succeeds, so recovery is tested rather than assumed. - What prevents failover from moving data outside the contracted region?
Each tier carries a residency attribute and policy excludes out-of-region tiers from the ladder, so a failover cannot quietly relocate processing.
Related architectures
- Part of enterprise ai compliance architecture.
- The same control appears in ISO/IEC 27001:2022 provider failover and degradation architecture.
- A different failure mode of the same component: fedRAMP Moderate provider failover and degradation architecture.
- SOX provider failover and degradation architecture for enterprise LLM applies the same mechanism under a different obligation.
- For the related constraint, see SOC 2 Type II provider failover and degradation architecture.
- If this is the blocker in front of you: enterprise AI infrastructure review.
Enterprise infrastructure review
If you are carrying this blocker, the useful next step is not a demo. It is a review of your actual request path against the control points above:
- Which of the 6 components exist in your estate today, and which are assumed
- Your current numbers against the 7 acceptance parameters, starting with p95 ≤ 600ms
- Which PCI DSS 4.0 control questions you cannot yet answer, and what closes each gap