Privacy by Design and Default Questions
Designing privacy into products, architectures and the software development lifecycle instead of bolting it on afterward. Covers the privacy-by-design principles and privacy-protective defaults, data minimization and purpose limitation at design time, personal-data flow mapping and PII inventory for a feature, consent and preference design including consent storage, enforcement across web and mobile and region-specific consent flows, retention and deletion design including legal holds, deletion across backups and immutable logs, provable deletion, and data-subject access, export and erasure flows, PII-safe logging, telemetry and session replay, on-device processing to limit data exposure, privacy-versus-personalization trade-offs, privacy in ML training data, feature stores and erasure from trained models, and privacy review gates, checklists, CI/CD checks, release readiness and requirements traceability inside engineering workflows. Includes designing privacy-first features, reference architectures, remediating privacy design flaws and rollout programs across product teams, and working with product, legal and security partners. Cryptographic and statistical privacy techniques, formal impact assessments, data-protection law, cross-border transfer rules, vendor risk, and encryption or access-control mechanics are covered elsewhere.
You are designing telemetry for a browser used by 500 million people. It needs consent choices, sampling, low client overhead and extra care for sensitive events. How would you architect collection and processing so privacy holds at that scale?
Sample Answer
Direct answer. Enforce privacy in the client and in automation, because at 500 million people no human review can keep up. The client checks consent before anything is queued, decides sampling locally, and can only send events declared in a schema. The server strips network identifiers at the edge, splits data by sensitivity, aggregates early, and refuses to show small groups.
Data tiers
- Essential diagnostics (crash counts, version, performance): minimal, no identifiers, collected under a legal basis (the lawful reason for processing, such as consent or a legitimate need) that counsel signs off.
- Optional usage (feature use): needs the user's choice, off if they decline.
- Sensitive events (anything related to browsing, search or content): not collected by default. If a question demands it, measure on-device and send only a coarse result. For example, the browser classifies pages locally and uploads a weekly count per category such as
{news: 41, shopping: 12}, never the URLs. A per-install count is still a small browsing profile, so add noise on the device before upload (local differential privacy: each client randomly flips or perturbs its answer, so any one report is deniable but the population totals can still be recovered), and send each report under a fresh random token rather than the install ID described below, because reports sharing one install ID could be chained together for as long as that ID lasts (30 days in the example).
Client design
- Consent: the choice is stored locally and checked before an event is queued, so "no" means nothing is created, not "created and dropped on the server".
- Sampling: the client decides once per metric per period using a local random draw. At 1% that is 5 million reporting clients (500,000,000 x 0.01). At an illustrative 20 events per day, that is 100 million events per day, around 20 GB per day at 200 bytes each. Of those 5,000,000 sampled clients, a feature used by 0.1% of users still shows up on 5,000 (5,000,000 x 0.001), enough to read, which is why 1% can be enough.
- Overhead: batch events, cap queue size and daily upload bytes, upload on idle and on unmetered networks (Wi-Fi rather than a capped mobile plan), and compress.
- Identity: a random install ID, created at install, replaced by a fresh random value on a schedule (say every 30 days, illustrative) with no link kept between old and new, and deleted on opt-out, never a cross-product account ID.
Schema as the enforcement point. Every event and field is declared in a registry with data category, purpose, retention, and owner. CI fails a change that adds an undeclared field, and the ingest service rejects unknown fields. This is how privacy scales across hundreds of engineers.
Server side
- Edge (the first servers that receive uploads, before anything reaches storage): drop IP addresses before logs (keeping only coarse country) and truncate the user agent (the browser's self-description string) to browser and major version.
- Separate stores per tier with different retention (raw 30 days, aggregates longer, illustrative) and access.
- Aggregate early, publish a cell (one row of a result table, such as one country plus browser version) only if it covers a minimum number of distinct clients (say 50, illustrative). A cell with 2 clients identifies them: if you know your colleague is one of the two, the cell's "visited a health site" count tells you about them.
- Automation: automatic expiry (TTL, time-to-live), access audit and an anomaly alert on large exports.
Trade-offs. Sampling reduces rare-event visibility, so use higher rates for crashes and low-volume features and say so in the schema. Rotating IDs break long-term retention analysis, which is the price of unlinkability.
What would change my call. Strict regional rules may require region-specific consent flows and storage location, which counsel decides. A measurement need that cannot be met with coarse data should go to a privacy review before collection, not after.
Design a GDPR-compliant event storage and deletion system that can delete all personal data for a user across both streaming and batch stores within 24 hours, while allowing continued computation of aggregate metrics. Describe storage layout, deletion propagation, tombstones, and strategies to preserve aggregate insights without retaining PII.
Sample Answer
Direct answer. Make the user key the organising principle of every store. Key all streams and tables by a stable user_id, keep PII out of the aggregate layer from the moment events are written, and run deletion as an event-driven workflow with a per-store checklist and a verification step. GDPR Article 17 requires erasure "without undue delay" and Article 12(3) allows a month; the 24 hours in the question is an internal service-level objective (SLO, a target the team sets for itself), tighter than the law, so treat it as a design target that leaves room for retries.
Storage layout
- Raw layer: events carry
user_idand PII fields. Short retention, restricted access. Together with the identity map below, this is the only place PII lives. - Derived layer: aggregates (counts by day, country, plan) written by jobs that drop
user_idand PII at write time. - Identity map: a small table linking
user_idto the PII (email, name). Erasing this row is the fast first step. - Partition the batch lake by date, and also keep a per-user index (user to files) so deletion does not scan the whole lake.
Deletion propagation
- User requests erasure. Write one
DeletionRequested(user_id, request_id)event to a durable queue. - Each store has an owner that consumes it and acknowledges completion. A coordinator table (one row per request and store, recording its state) tracks each store's state and raises an alert for any store still open after its budget.
- Streaming: for a compacted topic that holds current state per user (a profile or consent changelog), producing a tombstone (a record with that key and a null value) lets the compactor drop earlier records, and the tombstone itself is held for a configured period before it is removed. Compaction is not instant. Trace for Apache Kafka: compacted topic
user-profile, key42, offsets 10, 17 and 25 hold three updates for user 42. Producing offset 26 with key42and a null value is the tombstone. Once compaction runs over those segments, the log keeps only offset 26 for key 42, and after the tombstone retention period (thedelete.retention.mssetting) offset 26 is removed as well. Log compaction keeps only the latest record per key, so dropping older records is harmless on such state topics. On an append-only event topic keyed byuser_idit would also discard offsets 10 and 17 with no deletion at all, wiping history the aggregates may still need, so for event topics prefer the fallbacks below. On a compacted topic the tombstone path is the default, but it needs a bound to meet a 24 hour objective: compaction skips the active segment (the file still being written) and by default has no maximum delay, so setmax.compaction.lag.ms(Kafka's cap on how long a record may stay ineligible for compaction) well below the deadline, and rememberdelete.retention.msdefaults to one day, so the tombstone itself lingers. For topics that are not compacted, the fallbacks are to set retention below the deadline or to encrypt each user's events with a per-user key and delete the key (crypto-shredding: with the key gone, the encrypted events can no longer be read). - Batch: in a table format with row-level deletes (Delta Lake or Apache Iceberg style: the table is a set of immutable files plus a log of snapshots, meaning versions of the table), delete the rows, then expire old snapshots and clean up files. Trace: snapshot 7 points at file F1 holding user 42's rows; the delete writes snapshot 8 pointing at a rewritten F1' without them, but F1 stays on disk, and snapshot 7 still points at it, until snapshot 7 is expired and cleanup removes F1. Until old snapshots expire, deleted data is still physically present (Delta Lake's VACUUM keeps unreferenced files for 7 days by default, so the default alone would break a 24 hour claim and the retention must be lowered deliberately), which is the usual way a "deleted" user survives a 24 hour claim.
- Downstream copies (search index, caches, ML feature store, backups) are on the checklist. Backups are usually allowed to age out on a documented schedule, and counsel decides how to describe that to the user.
24 hour budget (illustrative split, hours)
| Step | Hours |
|---|---|
| Intake and queueing | 1 |
| Streaming purge | 4 |
| Batch rewrite and compaction | 12 |
| Snapshot expiry and verification | 4 |
| Buffer for retries | 3 |
| Total | 24 |
The 12 hours is a ceiling, not a measurement. For example, if the per-user index shows user 42's rows in 480 files and each file rewrite takes about 90 seconds run serially in the maintenance window, that is 480 x 90 / 3,600 = 12.0 hours; more workers shorten it, which is the main lever if the real number is larger.
Keeping aggregates without PII. Compute aggregates from the raw layer before it is erased, store them without user_id, and publish a bucket only when it covers at least a minimum number of distinct users (say 20, illustrative), so a small cell cannot single out a person. Recital 26 says information that cannot identify a person by "means reasonably likely to be used" falls outside data protection law, so an aggregate with large groups is fine. For example, a daily row "country=DE, plan=free: 1,350 active users" computed before user 42 was erased contains nothing that points at user 42, and 1,350 is far above the minimum of 20, so it stays; a cell that would show 3 users is merged into a wider bucket or withheld. Recomputing aggregates after each deletion is wrong for most metrics: it makes historical numbers shift. Accept that a deleted user's past contribution remains in a sufficiently large aggregate, and have counsel confirm that position. Metrics needing exact uniques (daily active users) can be stored as counts per day, not as user lists. Daily counts cannot be added into weekly or monthly uniques, because the same person appears on several days, so if those are needed store a mergeable sketch (a compact probabilistic summary, such as HyperLogLog, that can be combined across days without keeping user IDs) and check with counsel that it counts as non-identifying.
Verification. Run a nightly job that picks completed request IDs and searches every store for the user_id. Any hit pages the owner. Test with a synthetic user across all stores, including a late-arriving event written after the deletion request, which must be rejected by a tombstone check at ingest.
Trade-offs and pitfalls. Per-user indexes add storage but make deletion cheap. Late events, replays from a dead-letter queue (DLQ, where failed events are parked and later re-run) and backfills can resurrect deleted users unless every writer checks the deletion table.
Transaction records live in a primary database, cold archive and long-term backups. Design the retention and deletion plan so deletions reach every tier, and say how you would show later that they did.
Sample Answer
Short answer. Treat each tier as having its own deletion mechanism and its own deadline, drive all of them from one deletion ledger, and prove completion with per-tier receipts plus a recurring synthetic-subject test. Do not pretend backups can be edited; make them expire and make restores replay the ledger.
Step 0: decide what must be kept. Transaction records often have a legal retention duty (tax, accounting). GDPR's right to erasure has an exception for legal obligations (Art. 17(3)(b)), so the plan has two cases: (a) data past its retention period is deleted by schedule, (b) data a person asks to erase is deleted unless a legal duty requires keeping it, in which case you cut the link to the person where allowed and delete the rest. For example, an invoice is kept for the tax period and the profile row (account, preferences, marketing consent) is deleted. Whether the buyer's name and address on the invoice itself may be replaced depends on the tax rules: many jurisdictions require them on a VAT or sales invoice, and then the invoice stays intact under Art. 17(3)(b), access to it is limited to finance, and it is deleted when the retention period ends. Where the rules allow it, the customer id, name and email are replaced with a code and the amount, date and tax lines stay. Legal confirms the periods; the numbers below are illustrative.
Tier plan
| Tier | Deletion mechanism | Worst-case delay after the delete decision |
|---|---|---|
| Primary database | hard delete by key in dependency order (child rows before the parent rows they point to), idempotent (running it twice is safe: deleting an absent row counts as success) | 7 days |
| Cold archive (immutable files, which cannot be edited in place, split by month) | write the key to the ledger; a monthly compaction job (a batch job that reads each affected file and writes a new copy without the deleted people's rows, then removes the old file) runs; expired months are dropped whole | 7 + 31 = 38 days |
| Long-term backups (35-day rotation) | not edited; they expire; a restore replays the ledger before the data is served | 7 + 35 = 42 days |
The arithmetic: 7 days to delete from the primary, then the next monthly compaction is at most 31 days away, and the oldest backup that contains the row is at most 35 days old.
The deletion ledger. One append-only table (rows are only added, never changed) with a keyed hash (a scrambled fingerprint made with a secret key) of the subject key, the reason, the decision date and the scope. It holds no personal data in readable form. Every tier job reads the ledger, so a missed run catches up.
Traced request. A customer's erasure is decided on 2026-03-02. The primary database delete finishes by 2026-03-09 (7 days). The next monthly compaction removes the rows from the archive by 2026-04-09 at the latest (7 + 31 = 38 days). The oldest backup that still holds them has expired by 2026-04-13 (7 + 35 = 42 days). The ledger entry stays throughout, and the receipts for the three tiers are dated accordingly.
Showing later that it happened
- Each job writes a receipt: tier, ledger entry id, rows deleted, finish time.
- A reconciliation query per tier runs a lookup for ledger keys and must return zero rows (after the delay above).
- A synthetic customer is created in every tier, deleted by the same path, and checked monthly.
- A quarterly restore drill restores a backup in isolation and confirms the ledger replay removes the keys.
- Retention-schedule expiry produces the same receipts, so one report covers both cases.
Pitfalls. Soft-delete flags are not deletion. Derived copies (search index, warehouse export) need the same ledger. A restore without replay silently resurrects deleted people.
What would flip it: if backups are cheap to rewrite or short-lived (a few days), drop the replay design and let them expire. A regulator or counsel may require a shorter backup window; they decide.
The team building a supervised model wants every available customer attribute 'just in case'. How do you decide which personal data is actually needed, and how do you limit collection and retention without wrecking predictive performance?
Sample Answer
Direct answer
Start from the decision the model supports, not from the data available. Every attribute has to justify itself against that purpose, and I measure the justification instead of guessing. Data minimization means collecting and keeping only the personal data a stated purpose needs; purpose limitation means using data only for the purposes it was collected for.
Questions to ask before saying yes to an attribute
- Purpose: what prediction and what decision does it feed?
- Necessity: does the model get measurably worse without it?
- Existing consent and notice: were customers told this data would be used for modeling, and does the original purpose cover it?
- Policy: is it a special category (data types such as health or ethnicity that the law protects more strongly) or a proxy for one (a harmless-looking field that stands in for it, such as a postcode that mostly reveals ethnicity)?
Measure necessity
- Train a baseline with all candidate attributes and score it on a held-out split (rows set aside and never used for training, so the score reflects data the model has not seen).
- Group attributes (identity, contact, location, demographics, behaviour) and retrain with one group removed at a time. Compare the score (for example AUC, the area under the ROC curve, a ranking-quality measure) against the baseline.
- Keep a group only if removing it costs more than a margin agreed beforehand with the business (illustrative: half a point of AUC, 0.005). A tiny lift does not justify a sensitive attribute. Illustrative results: baseline AUC 0.842; without location 0.839 (a drop of 0.003, below the margin, so drop the group); without behaviour 0.781 (a drop of 0.061, far above it, so keep it).
Limit without wrecking performance: transform before dropping
| Instead of | Use |
|---|---|
| Birthdate | Age band or tenure in days |
| Exact location or postcode | Region or distance bucket |
| Free-text fields | Extracted flags, then drop the text |
| User ID, device ID, IP, user agent | Keyed hash (HMAC, a hash that needs a secret key; without the key nobody can recompute the pseudonym by hashing guesses) with the key held outside the data team |
| Raw event history | Aggregated counts and recency |
Pseudonymized data is still personal data, so the key and mapping stay access-controlled. Features to avoid: proxies for protected traits (postcode standing in for ethnicity) and anything derived from special-category data.
Retention
Keep raw columns only until features are extracted, then delete them. Store training snapshots with an expiry date and record which model used which snapshot, so a deletion request can be traced.
Trade-off
Fairness testing sometimes needs a sensitive attribute. Hold it in a separate, tightly controlled audit table used only for testing, never as a model input.
Tell me about a time you found data being used in a way that broke your company's privacy commitments, for example analytics using personal data without consent. What did you do, who did you tell, and how did you stop it recurring?
Sample Answer
Situation
At a previous company, I noticed while building a funnel report that the analytics events included email addresses for users who had declined the cookie banner. Our privacy notice said analytics ran only for users who opted in. The tool vendor's SDK (software development kit) was initialised before the consent check on one page type, so those events were collected anyway.
Actions I took
- Confirmed it first. I reproduced it in a test browser with consent declined, captured the network call showing the email field, and counted the affected event types in the warehouse (the central database where analytics data is stored for reporting), without opening any individual user's records.
- Contained it the same day. I told the engineer owning the page and asked for a feature flag (a switch in the code that turns a behaviour on or off without a new release) to stop the SDK loading before consent. I restricted warehouse access to the affected table until it was cleaned.
- Told the right people. I raised it with the privacy lead (the person who owns privacy decisions day to day; a data protection officer, or DPO, is the independent adviser some companies are legally required to appoint, if you have one), my manager and the analytics owner, in writing, with the evidence and what I did and did not know. Whether it counted as a reportable breach (one that must be notified to a regulator or to users) or needed user notice was their and legal's decision, not mine.
- Cleaned up. We deleted the non-consented events and the derived tables (reports and summaries built from those events), and recorded what was removed.
- Stopped it recurring. We added an automated test in CI (continuous integration) that loads each page with consent declined and fails if any analytics request fires, and added a consent-aware check to the tracking-plan review (the meeting where the team approves each new analytics event before it is built) for new events.
Result and reflection
The fix shipped within days, the CI check caught one later regression before release, and the privacy lead used the case to add analytics to the launch checklist. Next time I would raise it in the hour I confirmed it rather than the next morning, because the wait extended exposure.
What makes a strong answer
Show restraint (you do not investigate individuals), escalation (you do not decide legal questions alone), and a systemic fix (a test or gate, not "we reminded people").
Unlock Full Question Bank
Get access to all 21 Privacy by Design and Default interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.