Skip to main content
← PROBLEMS / SYSTEM-DESIGN
An end-to-end domain learning journey

Design a 50k RPS Distributed Secrets
Vault & Dynamic Credential Platform.

Design a HashiCorp Vault / AWS Secrets Manager-scale platform serving 50k RPS secret reads at <10 ms p99 with SPIFFE auth, dynamic DB leases, mlock() Edge Agents, and fail-closed HMAC audit logs.
Start the journey2 stages· Last modified Dec 2, 2026
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

When scaling secrets management, cache active leases in mlock() Edge Agents and keep Vault fail-closed on audit loss.

TL;DR30-second simplified summary
▾

Delivers <10 ms reads, 1M+ dynamic leases, and zero plaintext disk exposure.

Before you begin · Building blocksAlready know these? Jump to Stage 01 ↓
SPIFFE / OIDC Workload Identity
Cryptographic workload attestation eliminating static bootstrap secrets.
Envelope Encryption
Root -> KEK -> DEK hierarchy for O(1) rotation.
Full walkthrough · 2 stages
01
STAGE 01intermediate

SPIFFE Auth, Edge mlock() Agent & Fail-Closed Audit.

Why this matters: Eliminate secret zero, survive Vault outages safely, and enforce zero unlogged reads.

Workloads authenticate via SPIFFE SVIDs to a local Edge Agent that caches leases in mlock() RAM (never swap/disk). Vault core rejects reads if all audit sinks fail (fail-closed).

App (SPIFFE)Edge Agent (mlock)Vault Core (GCM)Ephemeral DB RoleHMAC Audit SinkUnix socketSVID authMint TTL roleFail-closed commit
ChoiceWhat it buysWhat it costs
Fail-Open AuditHigher availability during SIEM outageUnlogged secret reads violate zero-trust compliance
Fail-Closed Dual-Sink Audit + Edge mlock() CacheZero unlogged Vault reads; Edge Agents serve active leases during outageRequires dual audit sinks + mlock() agent deployment
import hmac, hashlib

def mask_audit_token(hmac_key: bytes, secret_value: str) -> str:
    return "hmac-sha256:" + hmac.new(hmac_key, secret_value.encode(), hashlib.sha256).hexdigest()
02
STAGE 02advanced

1M+ Dynamic Leases & 10ms Read Trace.

Why this matters: Scale ephemeral credential issuance and revocation without leaking orphaned DB roles.

1M active 1h leases = 278 creations/s and 278 revocations/s, managed by a sharded timing wheel. Dual-slot active/previous keys prevent rotation drops.

Workload / AgentVault Auth & ACLGCM Barrier & KMSDual Audit Sink1. 5ms: SPIFFE JWT verify & ACLcheck2. 0ms: DEK unwrap & AES-GCMdecrypt3. 0ms: Synchronous HMAC auditcommit4. 0ms: Return secret + 1h leaseTTL
Engineering Decision Framework
Problem
How to enforce strict zero-trust auditability (no unlogged secret reads) without taking down 50,000 RPS of production workloads if the central SIEM stalls.
Naive Solution
Configure Vault to fail-open on audit errors, or write secret caches to local plaintext files on every pod.
Why It Fails
Fail-open audit allows unlogged credential exfiltration during a SIEM attack; plaintext disk caches leak secrets in container snapshots and core dumps.
Alternatives
Fail-open logging, plaintext disk caching, or fail-closed dual-sink Vault auditing paired with swap-locked RAM (mlock) Edge Agents.
Engineering Decision
Keep Vault strictly fail-closed across two independent audit sinks (local disk + SIEM) while Edge Agents cache active leases in mlock() RAM until TTL expiry.
Trade-Offs
New lease issuance halts if both audit sinks fail simultaneously, but existing workloads continue running safely on their cached RAM leases.
Decision Exercise · Make the Call

Both the primary SIEM and secondary audit disk sink on a Vault leader fail simultaneously. What should Vault do?

public boolean issueSecret(boolean auditCommitted) {
    if (!auditCommitted) {
        throw new SecurityException("Fail-closed: all audit sinks failed");
    }
    return true;
}
Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

Why do Edge Secret Agents call mlock() on their lease cache memory?

Recommended Learning Flow