SD System Design In Depth
0%
lesson system-designdeletionprivacy

Data retention, deletion, and privacy

Module 5.1: Production Reliability, SLOs & Resilience Updated Sep 18, 2026
📄 Cheat Sheet
PEPR 2021: Session 4.1 - Deletion Framework: How Facebook Upholds its Commitments To Data Deletion
FutureofPrivacy PEPR 2021: Session 4.1 - Deletion Framework: How Facebook Upholds its Commitments To Data Deletion Watch on YouTube ↗

Meta engineers describe DELF, their production system for deleting data reliably across many data stores. It is a direct match for the distributed deletion problem in the lesson.

0:00 / --:--

Under the Hood: The Distributed Deletion Challenge

Deleting data in a single SQL table with DELETE FROM users WHERE id = ? is trivial; deleting user data across a distributed system with dozens of microservices, read replicas, search clusters, message queues, and append-only backups is one of the hardest operational challenges in software engineering. Regulatory mandates like GDPR (Right to Erasure) and CCPA require verified permanent erasure within legal windows (GDPR: without undue delay and within one month, extendable by two further months; CCPA: 45 days, extendable once by 45 more).

Distributed Deletion Orchestration Pipeline

sequenceDiagram autonumber actor User as Data Subject participant API as Privacy API Gateway participant Orch as Deletion Orchestrator participant DB as User Database (Primary) participant Kafka as Event Bus ('user.erased') participant Search as Elasticsearch Cluster participant S3 as Cold Storage / Data Lake User->>API: POST /v1/privacy/erasure-request API->>Orch: Schedule Async Erasure Workflow Orch->>DB: Soft-Delete + Anonymize PII (Immediate Lock) Orch->>Kafka: Publish 'user.erased' Event Kafka->>Search: Purge Documents by user_id Kafka->>S3: Cryptographic Shredding (Destroy KMS Key) Orch->>User: 202 Accepted (Audit Receipt Generated)

Core Production Deletion Mechanics

1. Tombstones and the Data Resurrection Hazard

In distributed LSM-tree and wide-column databases (Cassandra, Bigtable, RocksDB), deletes are not in-place physical overwrites. Instead, the storage engine writes a special marker record called a Tombstone. If a node is down during deletion and repairs after the tombstone's Garbage Collection Grace Period (gc_grace_seconds) expires, the resurrected old data is propagated back to healthy nodes as valid state. Production systems strictly coordinate repair intervals to occur well within tombstone expiration limits.

2. Cryptographic Shredding for Immutable Backups

Modifying historical immutable WAL archives or Glacier cold backups to erase a single user is physically impossible without re-writing entire multi-terabyte snapshot files. Production architectures solve this via Cryptographic Shredding: each user's sensitive PII is encrypted with a distinct per-user Data Encryption Key (DEK) managed in KMS. When an erasure request arrives, the orchestrator securely destroys the user's specific DEK. The encrypted ciphertext in cold backups becomes unrecoverable without rewriting historical media, provided no plaintext copies, cached DEKs or key backups remain.

3. Automated TTL Lifecycle Reapers

Data that is not retained cannot be breached. Production systems configure strict Time-To-Live (TTL) policies at the database layer (PostgreSQL partitioned table dropping, DynamoDB TTL attributes, Redis key expirations) to automatically purge ephemeral audit logs, session records, and abandoned shopping carts without manual batch scripts.

Retention schedule: decide the lifetime of data when you create it

Data classExample retentionMechanismNotes
Session tokensHours to 30 daysRedis TTL, DynamoDB TTLDynamoDB TTL deletes are asynchronous and typically happen within a few days of expiry, so filter expired items on read
Application logs containing personal data14 to 30 daysIndex lifecycle policies, bucket lifecycle rulesMask or hash identifiers at ingestion where possible
Analytics events13 months, then aggregateDropping date partitionsDROP PARTITION is instant; a row-by-row DELETE on billions of rows is not
Financial recordsOften 7 or more years (jurisdiction-specific)WORM storageLegal holds and retention obligations can override an erasure request for specific fields
Backups30 to 35 daysExpiry plus crypto-shreddingTell users that data in backups expires within the stated window

Worked example: an erasure request across 7 systems

A user's erasure request is published as a user.erased event. Each system that holds user data registers a deletion handler and must report completion:

  • Primary database: hard delete, or anonymise rows that must be kept for referential integrity (orders become "deleted user").
  • Search index: delete by user_id. Segment merges physically remove the documents later.
  • Cache: invalidate keys, or wait out a short TTL.
  • Data warehouse: rewrite the affected partitions, or use table-format deletes (Iceberg or Delta) followed by compaction and snapshot expiry. Old snapshots still contain the data until they expire.
  • Object storage: delete the objects, including all versions if bucket versioning is on.
  • Third-party processors: call their deletion APIs and record the confirmation.
  • Backups: destroy the user's data key, or let backups age out within the documented window.

The orchestrator tracks each handler's status and retries failures with backoff. It raises an alert if any handler has not completed by, for example, day 20, which leaves margin before a one-month deadline. Meta's DELF framework goes further: it requires every new data type to declare how it is deleted, and checks for data that was missed.

Failure modes

  • Resurrection: a stale replica, a cache refill from an old snapshot, or a Cassandra node that rejoins after gc_grace_seconds can bring deleted data back. Run repairs within the grace period.
  • Orphaned identifiers: deleting the user row but leaving their ID in event logs can let someone re-identify them by joining with another dataset.
  • Deleting audit evidence: keep a minimal, non-personal record that the deletion happened (a request ID, a timestamp and which systems confirmed), not the data itself.
Check yourself Question 1 of 3
Tombstone resurrection recall
From: Core Production Deletion Mechanics

A Cassandra node was offline for 14 days. gc_grace_seconds is 10 days, and deletes happened while it was down. It rejoins and repair runs. What is the risk?

Key Takeaways

In distributed wide-column and LSM storage, deletes write Tombstones; premature tombstone cleanup causes catastrophic data resurrection.
Use Cryptographic Shredding (destroying per-user KMS encryption keys) to achieve instant GDPR erasure across immutable cold backups.
Partition time-series audit tables by month or day so aging data can be dropped instantly via DROP TABLE instead of heavy DELETE scans.
Was this lesson helpful? Spot an issue or have a suggestion? Let us know on GitHub.
Report an issue