HIPAA reference architecture for enterprise LLM deployment at scale — Reference Architecture
Technical parameters
Every value below is a parameter you can hold a vendor or an internal team to. Adjectives are not acceptance criteria.
| Deployment vector | Dedicated inference tier with per-tenant admission control |
|---|---|
| Security standard | HIPAA |
| Applicable regimes | SOC 2 Type II, ISO/IEC 27001:2022, GDPR |
| Latency SLA | p95 ≤ 450ms — 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 Tenant-Fair Inference Tier, evaluated before the request reaches a model provider rather than audited afterwards. In regulated enterprise the binding constraint is HIPAA, and the question it actually asks is can PHI reach a place the BAA does not cover. The shape below holds p95 ≤ 450ms over REST over HTTPS, and ships with a standard-library implementation that runs as written.
Where the rollout actually stalls
A shared inference tier holds under average load and breaches its p95 under a neighbour's batch job. The SLA is written on a percentile, the dashboards show a mean, and admission control is a single global rate limit that protects the provider rather than any individual tenant.
What HIPAA specifically requires
HIPAA holds the covered entity responsible for PHI wherever it flows. A model provider without a signed BAA is not a permissible destination, and 'the prompt only contained a little PHI' is not a defence — the minimum necessary standard is itself a control.
The artifact that satisfies it is a de-identification record per request plus the BAA chain. The way teams most often fail it: PHI reaching a subprocessor with no BAA, via a logging sidecar nobody mapped.
The implementation — Per-tenant admission control and percentile tracking
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 minimum-necessary de-identification log.
"""Per-tenant admission control for a shared inference tier.
Why this shape: a global rate limit protects the provider and nobody else. The
failure enterprises actually hit is the noisy-neighbour one — tenant A's batch
job saturates the queue and tenant B breaches the p95 latency SLA that is
written into their contract. You cannot fix that downstream of admission.
Two controls, both required:
* a per-tenant token bucket, so one tenant cannot consume another's budget
* a global concurrency ceiling with per-tenant reservations, so the shared
tier degrades predictably instead of collapsing
"""
import heapq
import time
from dataclasses import dataclass, field
@dataclass
class TokenBucket:
rate: float # sustained requests per second
burst: float # instantaneous allowance
tokens: float = None
updated: float = field(default_factory=time.monotonic)
def __post_init__(self):
if self.rate <= 0 or self.burst <= 0:
raise ValueError("rate and burst must be positive")
if self.tokens is None:
self.tokens = self.burst
def take(self, n: float = 1.0, now: float = None) -> bool:
now = time.monotonic() if now is None else now
elapsed = max(0.0, now - self.updated)
self.tokens = min(self.burst, self.tokens + elapsed * self.rate)
self.updated = now
if self.tokens >= n:
self.tokens -= n
return True
return False
def retry_after(self, n: float = 1.0) -> float:
"""Seconds until n tokens exist. Return this in a 429 Retry-After so
clients back off correctly instead of hot-looping."""
deficit = max(0.0, n - self.tokens)
return deficit / self.rate
class Admission:
"""Per-tenant buckets plus a global concurrency ceiling with reservations.
reserved: tenant -> guaranteed in-flight slots. The sum of reservations
must stay below `ceiling`, or the guarantee is fiction.
"""
def __init__(self, ceiling: int, reserved: dict = None):
self.ceiling = ceiling
self.reserved = dict(reserved or {})
if sum(self.reserved.values()) > ceiling:
raise ValueError(
f"reservations {sum(self.reserved.values())} exceed ceiling "
f"{ceiling}: at least one tenant's SLA cannot be honoured")
self.buckets: dict = {}
self.inflight: dict = {}
def configure(self, tenant: str, rate: float, burst: float):
self.buckets[tenant] = TokenBucket(rate=rate, burst=burst)
def admit(self, tenant: str, cost: float = 1.0) -> tuple:
"""-> (admitted, reason, retry_after_seconds)"""
bucket = self.buckets.get(tenant)
if bucket is None:
return False, "tenant_not_provisioned", None
used = sum(self.inflight.values())
mine = self.inflight.get(tenant, 0)
my_reservation = self.reserved.get(tenant, 0)
# A tenant inside its reservation is admitted even when the shared pool
# is full — that is what makes the reservation worth signing.
if used >= self.ceiling and mine >= my_reservation:
return False, "global_ceiling", 0.05
if not bucket.take(cost):
return False, "tenant_rate_limit", round(bucket.retry_after(cost), 3)
self.inflight[tenant] = mine + 1
return True, "ok", None
def release(self, tenant: str):
self.inflight[tenant] = max(0, self.inflight.get(tenant, 0) - 1)
class LatencyWindow:
"""Streaming p95/p99 over a bounded window.
An average hides exactly the breach you are contractually exposed to: an
SLA is written on a percentile, so the number you alert on must be one.
"""
def __init__(self, size: int = 2048):
self.size = size
self.samples: list = []
def observe(self, ms: float):
self.samples.append(ms)
if len(self.samples) > self.size:
self.samples = self.samples[-self.size:]
def quantile(self, q: float) -> float:
if not self.samples:
return 0.0
ordered = sorted(self.samples)
# Nearest-rank: the smallest sample at or above the q-th position.
idx = min(len(ordered) - 1, max(0, int(round(q * len(ordered) + 0.5)) - 1))
return ordered[idx]
def breach(self, slo_ms: float, q: float = 0.95) -> bool:
return self.quantile(q) > slo_ms
if __name__ == "__main__":
adm = Admission(ceiling=10, reserved={"bank-eu": 4})
adm.configure("bank-eu", rate=5, burst=5)
adm.configure("retail-us", rate=50, burst=50)
for _ in range(9):
adm.admit("retail-us")
print("noisy neighbour holds", adm.inflight)
print("reserved tenant still admitted:", adm.admit("bank-eu"))
print("burst exhausted ->", [adm.admit("bank-eu") for _ in range(5)][-1])
win = LatencyWindow()
for ms in [120, 140, 135, 128, 900, 131, 139, 142, 150, 2200]:
win.observe(ms)
print(f"p95={win.quantile(0.95):.0f}ms breach(400ms)={win.breach(400)}")
The HIPAA control, as code
Minimum-necessary de-identification with a BAA-pinned egress gate. This is the artifact an assessor asks for under HIPAA 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.
"""Minimum-necessary de-identification with a BAA-pinned destination gate.
HIPAA holds the covered entity responsible for PHI wherever it flows, so the
control is not "we told people not to paste PHI". Two things must be
structural: PHI is reduced to the minimum necessary BEFORE egress, and the
destination set is pinned to those under a signed BAA, failing closed on
anything else.
Safe Harbor (45 CFR 164.514(b)(2)) lists 18 identifier classes. This implements
the mechanical subset and records a per-request de-identification receipt,
because the auditor asks for proof per request, not a policy document.
"""
import re
SAFE_HARBOR_PATTERNS = {
"name_mrn": re.compile(r"\bMRN[:\s#]*([A-Z0-9-]{4,})", re.I),
"ssn": re.compile(r"\b\d{3}-\d{2}-\d{4}\b"),
"phone": re.compile(r"\b(?:\+1[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}\b"),
"email": re.compile(r"\b[\w.+-]+@[\w-]+\.[\w.]+\b"),
"date_full": re.compile(r"\b\d{1,2}/\d{1,2}/(19|20)\d{2}\b"),
"member_id": re.compile(r"\b(?:member|policy)\s*(?:id|#)[:\s]*([A-Z0-9-]{5,})", re.I),
}
class BAARegistry:
"""Destinations are permissible only as attested data, never by convention."""
def __init__(self):
self._signed: dict[str, str] = {}
def attest(self, destination: str, agreement_ref: str) -> None:
self._signed[destination] = agreement_ref
def covered(self, destination: str) -> bool:
return destination in self._signed
def reference(self, destination: str) -> str | None:
return self._signed.get(destination)
class PHIEgressGate:
def __init__(self, registry: BAARegistry):
self.registry = registry
self.receipts: list[dict] = []
def deidentify(self, text: str) -> tuple[str, dict[str, int]]:
counts: dict[str, int] = {}
out = text
for label, pattern in SAFE_HARBOR_PATTERNS.items():
out, n = pattern.subn(f"[REDACTED:{label}]", out)
if n:
counts[label] = n
return out, counts
def send(self, text: str, destination: str) -> dict:
"""Refuses rather than redacting-and-hoping when the BAA is absent."""
redacted, counts = self.deidentify(text)
phi_present = bool(counts)
if phi_present and not self.registry.covered(destination):
receipt = {"destination": destination, "admitted": False,
"reason": "no BAA on file for a PHI-classified payload",
"identifier_classes": sorted(counts)}
self.receipts.append(receipt)
raise PermissionError(receipt["reason"])
receipt = {
"destination": destination,
"admitted": True,
"baa_ref": self.registry.reference(destination),
"identifier_classes": sorted(counts),
"redactions": sum(counts.values()),
"payload": redacted,
}
self.receipts.append(receipt)
return receipt
if __name__ == "__main__":
reg = BAARegistry()
reg.attest("azure-openai-us-east", "BAA-2026-0041")
gate = PHIEgressGate(reg)
note = ("Patient MRN: 88213A, contact 555-867-5309 or a.patient@example.com, "
"DOB 04/11/1974, follow-up scheduled.")
ok = gate.send(note, "azure-openai-us-east")
assert ok["admitted"] and ok["redactions"] >= 4, ok
assert "88213A" not in ok["payload"] and "555-867-5309" not in ok["payload"], ok
assert "a.patient@example.com" not in ok["payload"], ok
try:
gate.send(note, "some-vendor-eval-endpoint")
raise AssertionError("PHI reached a destination with no BAA")
except PermissionError:
pass
# No PHI means no BAA requirement — the gate must not over-block.
benign = gate.send("Summarise ward occupancy trends.", "some-vendor-eval-endpoint")
assert benign["admitted"] and benign["redactions"] == 0, benign
print("HIPAA minimum-necessary egress gate: OK")
print(f" receipts {len(gate.receipts)}, "
f"refusals {sum(1 for r in gate.receipts if not r['admitted'])}")
The request path
Tenant-Fair Inference Tier — the request path, with the decision points that must exist before the first model call:
flowchart TB
subgraph Tenants
TA[Tenant A - batch]
TB[Tenant B - interactive p95 400ms]
end
TA --> AD{Admission}
TB --> AD
AD -->|bucket empty| S429[429 + Retry-After]
AD -->|ceiling full,<br/>outside reservation| S429
AD -->|admit| Q[Deadline queue]
Q -->|deadline passed| SH[Shed - do not serve late]
Q --> W[Worker pool]
W --> P[Model / vLLM]
P --> OBS[Per-tenant p95 / p99 window]
OBS -->|breach| ALERT[Page + autoscale signal]The parts you have to build
- Per-tenant token bucket — Sustained rate plus burst, so one tenant cannot spend another's budget.
- Reservation ledger — Guaranteed in-flight slots per tenant; reservations must sum below the ceiling.
- Global concurrency ceiling — Bounds the shared tier so it degrades predictably instead of collapsing.
- Percentile window — Streaming p95/p99 per tenant — the number the contract is written on.
- Queue with deadline — Requests carry a deadline and are shed rather than served late.
- Shed path — 429 with an accurate Retry-After so clients back off instead of hot-looping.
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 |
|---|---|---|---|
| HIPAA | PHI egresses to a provider or subprocessor outside the BAA chain | Classify and de-identify before egress; pin destinations to the BAA-covered set and fail closed on anything else | 0 requests to non-BAA destinations; de-identification applied pre-egress on 100% of PHI-classified payloads |
| Latency SLA | One tenant's batch traffic breaches another's contractual p95 | Per-tenant token buckets plus reserved in-flight slots inside a global ceiling | Reserved tenants hold p95 under their SLO while a neighbour saturates the tier |
| Latency SLA | Mean latency hides the percentile the contract is written on | Track streaming p95/p99 per tenant; alert on the percentile, never the average | Alert fires on p95 breach within one window; mean is dashboard-only |
| Latency SLA | Late responses served instead of shed, so queues grow unboundedly | Attach a deadline to every request and shed on expiry | 0 responses served after deadline; shed rate published per tenant |
| Data privacy | Cross-tenant leakage through a shared cache or KV reuse | Namespace every cache key by tenant id; never key on prompt text alone | Cache key audit shows 100% tenant-namespaced; cross-tenant hit rate 0 |
| Cost control | Over-provisioning GPU to absorb one tenant's bursts | Bound burst at the bucket, scale on admitted load rather than offered load | GPU utilisation 60-80%; scaling driven by admitted load |
| Cost control | Retries amplify a degradation into an outage | Accurate Retry-After, client backoff, and a circuit breaker on the shed path | Retry amplification under 1.3x during an induced degradation |
| Operational | Reservations sum above the ceiling, so guarantees are fiction | Validate at configuration time; refuse to start with over-committed reservations | Startup check rejects over-commitment; covered by a unit test |
Review questions and answers
- Which destinations hold a BAA, and what structurally prevents PHI from reaching one that does not?
Destinations carry a BAA flag as attested data, and the routing gate refuses a PHI-classified payload to any destination without it. The refusal is logged with its reason. - Which tenants have contractual percentile targets, and what reserves capacity for them?
Any tenant with a contractual percentile gets an entry in the reservation ledger — guaranteed in-flight slots inside the global ceiling. Reservations are validated at configuration time and must sum below the ceiling. - What happens to tenant B's p95 when tenant A sends 10x its normal volume — measured, not assumed?
Tenant B stays inside its SLO, because tenant A is bounded by its own token bucket and cannot consume B's reserved slots. This is testable: saturate A and watch B's p95 window. - Is the alert on a percentile or a mean?
A percentile. The SLA is written on p95, so the alert is on p95. The mean is dashboard-only, because it hides exactly the breach you are contractually exposed to. - What is shed under saturation, and how does a client learn when to retry?
Requests past their deadline are shed rather than served late, and the shed path returns 429 with an accurate Retry-After computed from the bucket's refill rate so clients back off instead of hot-looping. - Can a cache entry created for one tenant ever be served to another?
No. Every cache key is namespaced by tenant id; keying on prompt text alone is the mechanism by which one tenant's completion is served to another.
Related reference architectures
- Part of enterprise llm architecture at scale.
- This pattern also governs enterprise LLM deployment at scale in fintech.
- fedRAMP Moderate reference architecture for enterprise LLM deployment covers the adjacent case.
- The same control appears in ISO/IEC 27001:2022 reference architecture for enterprise LLM deployment.
- 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 ≤ 450ms
- Which HIPAA control questions you cannot yet answer, and what closes each gap