KatInterview

Design an Immutable Multi-Tenant Audit Log System

System DesignModel answer
HardModel answerSystem Designaudit-loggingcryptographymulti-tenancy

Last updated

Design a compliance audit logging platform that ingests events at scale, proves tamper-evidence cryptographically, detects sequence gaps, and serves fast investigation queries.

Context

A legal-tech platform serves thousands of corporate and government customers across a suite of independently deployed microservices — contract execution, document search, litigation holds, permission management, and more. Regulators and enterprise compliance officers require a complete, tamper-proof record of every user, API, and system action.

You are asked to design a centralized audit log platform. It must reliably accept events from all upstream services, store them immutably with cryptographic integrity guarantees, detect any missing records automatically, and answer investigator queries quickly.

Functional Requirements

  • Canonical ingestion: Accept structured audit events from heterogeneous services. Validate against a schema, enforce tenant isolation, and handle client-side retries without creating duplicate records.
  • Tamper evidence and immutability: Guarantee that no internal operator or compromised service credential can silently alter or delete records. A third-party auditor must be able to independently verify ledger integrity.
  • Gap detection and replay: Automatically identify missing sequences or silent delivery failures from producer services and coordinate replay without duplicating existing records.
  • Investigation queries: Support sub-second-to-low-second filtered searches by tenant, actor, action, resource ID, and time range for forensic and compliance use cases.
  • Privacy-compliant redaction: Satisfy "right to erasure" requests (GDPR/CCPA style) within an append-only architecture, without breaking cryptographic verification of surrounding records.

Non-Functional Requirements

  • Durability and availability: 99.999% durability, zero data loss. The ingestion path must stay available (99.99%) even during background compaction or index rebuilds.
  • Scale: 50,000 tenants; 1 billion events per day (~12,000/s average, ~40,000/s peak). Seven-year retention.
  • Query performance: Queries over the last 30 days must return within 3 seconds; multi-year cold queries within 30 seconds.
  • Blast radius: A single high-volume tenant or compromised producer must not degrade service for others.

What Is Expected

Walk through your full design covering:

  1. End-to-end architecture — ingestion pipeline, transport, buffering, validation, and storage tiering (hot vs. warm vs. cold).
  2. Tamper-evidence data model — the cryptographic mechanism (hash chains, Merkle trees, external anchoring), event schema, and how erasure requests interact with integrity proofs.
  3. Reliability and operational controls — SLIs/SLOs, gap detection logic, backpressure, deduplication strategy, and key management for cryptographic shredding.

Go deep on at least two of those three areas. Mention trade-offs wherever you make a choice.

Hints

Hint 1

Start by sizing the system: 1B events/day at ~1 KB each is roughly 1 TB/day raw. Work out what that means for hot storage (30 days ≈ 30 TB), total retention (~2.5 PB before compression), and the throughput headroom you need to build in above 40k/s peak.

Hint 2

Tamper evidence has two distinct problems: proving a record hasn't changed (hash chains / Merkle trees), and proving an insider hasn't rewritten both the data and the hashes (external anchoring to an independent account or transparency log). You need both, and they have different trust assumptions.

Hint 3

Gap detection depends on producers emitting monotonic sequence numbers per stream and sending heartbeats even when idle. Without heartbeats, a completely silent producer looks identical to a healthy one — the platform can't distinguish 'no events' from 'events lost'.