System designDeep dive12 min

Privacy, residency & retention

Personal data comes with duties attached: keep only what you need, know every place it lives, delete it on time and on request, and keep it in the places you promised. Each duty sounds like policy, but each one fails or succeeds in the architecture: in the copies you didn't map, the backups you can't edit, and the support tool that reads from another continent.

1 · The problem

Personal data is a liability with a lifetime, and it hides in copies

A recruiting platform connects job seekers in Europe and North America with employers. Lena, an applicant in Berlin, finds a job and writes: please delete everything you hold about me. The account row takes a second to remove. Then the team starts counting where else Lena's data lives:

Place

What it holds about Lena

Profile database

Name, email, phone, work history

Object storage

Three uploaded CVs and a cover letter

Search index

A copy of the profile, so recruiters can find it

Cache

Recently viewed profile pages

Analytics warehouse

Application events with Lena's user id, copied nightly

Logs

Request logs with Lena's email in some URLs

Email provider

Every message the platform sent Lena

Backups

Nightly database snapshots for the last 35 days

Each copy was made for a good reason, and none of them was designed with deletion in mind. That's the pattern this page is about. Personal data is any information relating to an identified or identifiable person; the EU's General Data Protection Regulation (GDPR) uses that definition, and it covers ids and online identifiers as well as names. Laws like it turn a handful of principles into engineering requirements. Other jurisdictions have similar rules: California's, for example, gives consumers rights to know and to delete.

2 · The rules

A few legal principles become concrete requirements for the system

The GDPR's principles and rights translate fairly directly into things a system must be able to do:

Rule

What the law says

What the system needs

Purpose limitation

Collected for specified purposes, not reused for incompatible ones

A recorded purpose for each kind of data

Data minimization

Limited to what is necessary

Fields justified at design time; fewer copies

Storage limitation

Kept in identifiable form no longer than necessary

A retention period per data class, enforced

Access and portability

A copy of one's data; machine-readable where portability applies

Find and export everything for one person

Erasure

Erase without undue delay when a ground applies

Delete one person everywhere, and prove it

By default

Only necessary data processed, including how long it's stored

Short retention and narrow access as defaults

The deadlines are short. A request like Lena's must be answered without undue delay and within one month, extendable by two further months for complex or numerous requests. A personal data breach must be reported to the regulator without undue delay and, where feasible, within 72 hours of becoming aware of it, unless it is unlikely to put people at risk. The largest fines reach €20 million or 4% of worldwide annual turnover, whichever is higher.

Erasure isn't absolute. The right gives way where keeping the data is necessary to comply with a legal obligation, or to establish, exercise or defend legal claims, among other exceptions. So a deletion system needs exceptions as data, not as ad hoc judgment: Lena's invoices for a paid premium plan may have to stay, while everything else goes.

3 · The data map

You can't delete what you can't find, so map personal data before it spreads

The GDPR requires a record of processing activities: for each purpose, the categories of people and data, who receives it, any transfers abroad and, where possible, the time limits for erasure. Kept as a document, it goes stale within months. Kept as part of the system, it becomes the map that deletion, export and retention run on:

Profile serviceowns subject 7731Profile databasetagged: personalChange streamcarries subject idSearch indexderived copyWarehousepseudonymous idwriteevery changeindexnightly loadProfile serviceowns subject 7731Profile databasetagged: personalChange streamcarries subject idSearch indexderived copyWarehousepseudonymous idwriteevery changeindexnightly load

Every copy is derived from the source through a known path, and every record carries the same subject id. Deleting at the source then flows to the copies the same way updates do.

The practices that make the map real:

  • Tag personal fields in the schema, so tooling can find them, mask them in logs and include them in exports.
  • Carry one subject id everywhere, so a single key finds a person in every store, instead of matching names and emails.
  • Derive copies through known paths, such as a change stream (Change data capture), rather than ad hoc exports nobody tracks.
  • List outside recipients, such as the email provider: when data has been disclosed to others, each must be told about the erasure, unless that proves impossible or takes disproportionate effort.

Pseudonymization helps without changing the legal status. Replacing Lena's email with a random id in the warehouse means analysts never see who Lena is. But pseudonymous data that can be linked back with additional information is still personal data; only data that is truly anonymous, where nobody can be identified by any means reasonably likely to be used, falls outside the rules. A warehouse keyed by a reversible id still needs deletion.

4 · Erasure

Deletion is a tracked workflow across every copy, backups included

A request to delete subject 7731 becomes a job with a checklist, not a single SQL statement. A privacy service records the request, works out which exceptions apply, fans the deletion out to every system in the map, and only reports success when each one has confirmed:

Each system confirms, and the job stays open until all have. A system that is down gets retried; nothing is reported to Lena as done until it is.

Backups are the hard case, because rewriting old snapshots is slow and risky. Erasure must reach backups too, but regulators accept that data may stay in a backup until it is overwritten on its normal schedule, provided it is put beyond use: not used for any other purpose, and the person is told clearly what will happen. One consequence is easy to miss: restoring a backup brings Lena back, so every restore has to replay the deletions recorded since that backup was taken.

Crypto-shredding is the other way through immutable copies: encrypt each person's data with their own key and delete the key, which makes every copy unreadable at once, backups included (Encryption in transit & at rest). Event logs that must never be edited use the same trick (Event sourcing & CQRS). It works only if the key itself is never copied into the backups it is meant to cut off.

Whether destroying a key legally counts as erasure is still debated: regulators accept it in some cases as putting data beyond use, so check with whoever answers for compliance before relying on it alone.

5 · Retention

Every class of data needs a clock, or keeping everything becomes the default

Most personal data isn't deleted because someone asked; it's deleted because its purpose ended. Without a rule, it never is. Suppose the platform gains 100,000 applicants a month and keeps everything forever: after three years it holds 3.6 million profiles, most of people who stopped looking long ago. A rule that deletes a profile 12 months after its last activity caps the total:

  • Keep forever
  • Delete after 12 months idle
01230102030Months since launchProfiles held (M)First deletions

100,000 new profiles a month: kept forever, 0.1 M × months; with deletion after 12 idle months, at most 0.1 M × 12 = 1.2 M, assuming nobody returns. Every profile past the line is breach exposure with no purpose.

A retention schedule gives each class of data a period and a reason, set by the legal team and enforced by the system. For the platform, the schedule might read:

Data class

Kept for

Why

Active profile

Until 12 months without activity

The service the applicant signed up for

Application to a job

6 months after the decision

The platform's policy for answering disputes

Invoices

As long as tax law requires

A legal obligation, so erasure requests don't apply

Request logs

30 days

Debugging and security; emails masked

Data under legal hold

Until the hold is lifted

A dispute or investigation overrides the clock

The periods above are the example's policy, not legal advice: the right period depends on the purpose and the jurisdiction. The mechanics are covered in Data lifecycle: tiering, TTL & compression: a TTL on rows and objects, lifecycle rules on storage, and partitions dropped whole. Two rules make them trustworthy: the deletion job is monitored like any other job, and a legal hold is a flag the job checks, not a manual pause.

6 · Residency

Residency covers every copy and every remote access, not just the database's region

A large German employer asks: is our applicants' data kept in the EU? Under the GDPR, personal data may be transferred outside the European Economic Area only under the regulation's transfer rules: to a country the European Commission has found adequate, or with appropriate safeguards such as the Commission's standard contractual clauses. Remote access from a third country, for example during support, also counts as a transfer.

The rules can shift under a running system. In July 2020 the EU's Court of Justice invalidated the adequacy decision for the EU-US Privacy Shield. In May 2023 Ireland's regulator fined Meta €1.2 billion for continuing to transfer Facebook users' data to the US on standard contractual clauses after that ruling, and ordered it to suspend the transfers. In July 2023 the Commission adopted a new adequacy decision, the EU-US Data Privacy Framework, for US companies that participate in it.

For a system, residency means a regional deployment per jurisdiction, with each person's data placed in one region and a thin global layer that holds as little as possible:

Applicantsigns inGlobal directoryaccount id → region onlyEU regionall copies, backups tooUS regionUS applicants' datawhich region?Lena: EUothers

Each person's data, with its search index, logs and backups, stays in one region. The global layer knows only where to send a request.

The database is rarely what breaks residency. The usual leaks are the copies and accesses around it:

Leak

How it happens

Backups and replicas

Disaster-recovery copies configured to another region (Multi-region replication)

Logs and error reports

Shipped to a central tool hosted in another country

Analytics

Loaded into one global warehouse

Support access

Staff abroad opening EU records, which counts as a transfer

Third-party services

Email delivery and similar vendors, each with its own data locations

Cloud providers let you choose the regions where data is stored, and AWS, for example, commits not to move content out of the chosen regions without agreement, except as needed to provide the service or comply with the law. Everything you build on top is your own responsibility. In a multi-tenant product, a region is usually a separate deployment stamp (Multi-tenancy).

7 · The checklist

Privacy is cheapest when it's designed in, and expensive when it's retrofitted

The GDPR calls this data protection by design and by default: measures built in when the system is designed, and defaults that collect, keep and expose only what each purpose needs. For the recruiting platform:

Decision

Recruiting platform choice

What to collect

Only fields with a recorded purpose; no date of birth

Where it lives

A data map from tagged schemas and change streams, kept by the system

How to find a person

One subject id in every store; pseudonymous ids in analytics

Erasure

A privacy service that fans out, tracks confirmations and logs exceptions

Backups

Beyond use until overwritten; deletions replayed after any restore

Retention

A schedule per data class, enforced by monitored jobs, with legal holds as flags

Residency

One region per person, thin global directory, logs and support kept in region

Breaches

Detection and an incident plan that can notify within 72 hours (Audit logging)

Check yourself

4 questions

1. The warehouse replaces names and emails with random ids, and a lookup table maps ids back to people. Is the warehouse data still personal data?
2. Lena's data is deleted from the live systems, but nightly backups for the last 35 days still contain it. What do regulators expect?
3. All EU applicants' data is stored in an EU region. Which of these is still a transfer outside the EEA?
4. Why does a retention schedule need to be enforced by monitored jobs, and not just written down?

Takeaways

Remember this

  • Personal data is any information relating to an identifiable person, including ids; pseudonymized data is still personal data while it can be linked back.
  • Map every copy of personal data and carry one subject id everywhere, or deletion and export can't be complete.
  • Erasure is a tracked workflow across every system and recipient; backups can wait until overwritten if the data is put beyond use.
  • Give each class of data a retention period and enforce it with monitored jobs, with legal holds as flags.
  • Residency covers backups, logs, analytics, vendors and remote access, not just the primary database's region.