Practice: Tinder
Design a dating discovery service that returns eligible nearby profiles, records directional swipes, and creates one match after reciprocal likes.
Design a dating discovery service that returns eligible nearby profiles, records directional swipes, and creates one match after reciprocal likes.
Write your own design before opening hints or the solution review. The numbers below are exercise assumptions, not claims about any company’s production traffic. You may challenge an assumption, but record the replacement and explain which decision changes.
Scenario and constraints
- Assume 50 million monthly active users and 5 million candidate refreshes per minute at peak.
- A profile preference/location update should affect new candidate pages within 60 seconds.
- A user may see at most 100 candidates per refresh; exact prior-swipe exclusion is required.
- Messaging is outside scope; a match notification may be delivered asynchronously.
Your deliverables
- Define profile, preference, directed swipe, canonical pair, match, and notification identities.
- Calculate candidate query load and compare geo-cell filtering with exact distance and eligibility checks.
- Show how two reciprocal swipes serialize on one pair and create one durable match/outbox record.
- Explain candidate cache freshness, exact seen-set fallback, and location/privacy authorization.
Reason about this sequence
Read the diagram
A likes B → B likes A concurrently → Both likes persist once → Canonical pair is inserted once → One match event notifies both
For every step, annotate what is durable, what the caller knows, and which identity survives a retry. Identify the point where two concurrent actors could disagree. Do not assume a timeout means failure or a cache value grants ownership.
Interviewer follow-ups
- Both users like each other at the same instant on different application servers. Which transaction creates the match?
- The match commits but notification delivery times out. How does replay avoid duplicate notifications?
- A cached candidate remains after a block or location change. Where is eligibility rechecked?
Answer each follow-up using the same design first. If it breaks, change the smallest boundary that repairs the invariant and explain the new cost. Show whether the change adds latency, storage, coordination, or operational work.
Staged hints
Hint 1 — reveal
Answer: Hint 1 — Partition pair decisions by a canonical unordered user pair; candidate proximity never implies consent or match ownership.
Hint 2 — reveal
Answer: Hint 2 — Keep profile facts, preferences, location cells, directional Likes, Blocks, and Match records distinct. Enforce one logical Like per actor-target pair and one Match per unordered pair. Match creation must recheck both directions and block status at an authoritative boundary. Candidate pools are derived, versioned, and rebuildable; they do not grant visibility.
Hint 3 — reveal
Answer: Hint 3 — A user blocks someone whose card is already cached and whose like is pending. Block state must be authoritative at the interaction and message boundary. Remove the person from future candidate responses asynchronously, while the final read check prevents access during propagation. Define whether an existing match is removed and preserve an audit event consistent with the privacy policy.
Evidence-based self-review
- Candidate search is separate from mutual-interest and consent authority.
- Each directed swipe is idempotent; one canonical pair identity serializes reciprocal decisions.
- A unique match and notification intent commit together, with retry-safe delivery.
- Cache refresh and exact seen-state behavior respect privacy, blocks, and stated freshness.
Score each item 0 if absent, 1 if named without an enforceable mechanism, or 2 if the mechanism and a failure are explained. Record evidence from your own diagram beside the score. Then choose one weak decision, revise it, and repeat the relevant follow-up. This rubric is a learning tool, not a hiring forecast.
Clarify this prompt before choosing components
Ask the highest-impact questions first, agree on priorities, and record the interviewer’s answers. If a detail is unspecified, state an assumption and explain which decision depends on it. The numbers in this worked lesson are exercise assumptions, not company facts.
| Ask the interviewer | Why the answer changes the design |
|---|---|
| Discovery only or matches and chat too? | Reciprocal-like transitions and messaging need separate owners. |
| Distance accuracy, privacy and allowed location staleness? | Choose coarse candidate indexing and exact eligibility boundaries. |
| Can blocked or already exposed candidates appear? | Live policy and exposure filtering must run before returning cached candidates. |
Use the Interview Playbook for the shared 45-minute sequence and fresher, intermediate, senior and staff evidence. Start with one complete operation. Extend the answer with the failure/recovery traces below, then defend a workload-specific alternative and a measurable rollout. Scope and evidence matter more than a large component list.
Reveal the full worked solution
Save your attempt before continuing.
Tinder: Understand the building blocks
Choose a mechanism because it satisfies a requirement. These explanations describe the exercise design, not undisclosed implementation choices at the named company.
Tinder: Quick vocabulary
| Term | Meaning and role in this exercise |
|---|---|
| API: Application Programming Interface | The contract for requests, responses and errors between components. An API route does not itself enforce every business invariant. |
| PK: Primary Key | The declared row identity in a database schema; it does not automatically enforce every cross-row business rule. |
Tinder: Spatial index and exact distance filter
What it means: An index that groups positions so a nearby query examines a bounded candidate set instead of scanning every location.
Why this problem needs it: Discovery narrows nearby profiles before expensive ranking.
How to use it: Search cells or bounding regions that intersect the requested radius, including boundaries, then compute exact distance and current eligibility for candidates.
Example in this design: Search neighboring cells and then current distance/eligibility instead of assuming one cell contains all nearby users.
When it fits: Useful when frequent nearby queries make a full scan too expensive.
Alternative and limits: A small dataset may need only a scan. Geohashes, quadtrees and spatial database indexes have different update, precision and query costs. Proximity does not imply availability.
Tinder: Canonical pair identity and uniqueness
What it means: A canonical identity gives equivalent representations of one logical object the same key, such as ordering the two user IDs in an unordered pair.
Why this problem needs it: Reciprocal likes may be processed by different workers.
How to use it: Normalize the pair, atomically enforce a unique key and persist its result; replays return that same object under current policy.
Example in this design: Both target canonical pair(A,B); one match m7 wins under uniqueness.
When it fits: Useful for one match per pair or one owned relation despite simultaneous creators.
Alternative and limits: A per-pair serial owner is another coordination approach. Two read-then-create calls without an enforcing unique boundary can both succeed.
Tinder: Idempotency key and stored operation result
What it means: Idempotency means replaying the same logical operation produces no additional business effect. A key identifies that operation under a defined scope.
Why this problem needs it: Like/match retries should reuse the same intent/result.
How to use it: Atomically associate a request key and payload fingerprint with its effect and result. Return the stored result on replay; reject incompatible payload reuse.
Example in this design: A retried mutual-match creation returns m7 rather than another match.
When it fits: Needed when a timeout can hide a successful commit or a queue can redeliver.
Alternative and limits: Unique business identities can enforce selected effects. A cache of recent requests alone may expire too early or race; local keys cannot control an uncooperative external provider.
Tinder: Access Control List (ACL) and current authorization
What it means: An ACL records which principals may perform specified actions on an object. Authorization evaluates the applicable current policy for this request.
Why this problem needs it: A candidate cursor is not permanent permission to interact.
How to use it: Authenticate the caller, evaluate object/tenant membership and permission version at the required disclosure/mutation boundary, and declare caching/revocation behavior.
Example in this design: A later block prevents the disallowed like/message despite a stale visible profile card.
When it fits: Needed when object access can change while connections, projections or cursors remain alive.
Alternative and limits: Capabilities/signed grants can fit a bounded expiry policy. A valid cursor, cached candidate or open socket is not permanent permission.
Interview scope and guarantees
Show a bounded set of nearby eligible profiles, record likes or passes, create a match when likes are mutual, and let matched users start a conversation. Location and recommendations may be stale; match identity and blocks require enforced rules.
Capacity worksheet
Assume 5 million daily users perform 100 swipes: 500 million/day, about 5,787/s average and 28,935/s at 5× peak. A 100-byte swipe record adds 50 GB/day raw. Do not compute pairwise scores for all users; retrieve a small eligible candidate set first.
Concrete API contract
GET /recommendations?cursor=...
POST /swipes {targetId,decision,requestId}
GET /matches?cursor=...
POST /blocks {targetId}Data model and access paths
swipes(actor_id,target_id,decision,version); UNIQUE(actor_id,target_id)
matches(match_id PK,low_user_id,high_user_id,generation,state,created_at); UNIQUE(low_user_id,high_user_id,generation)
UNIQUE(low_user_id,high_user_id) WHERE state=active
profiles(user_id PK, coarse_cell, preferences, updated_at)
blocks(actor_id,target_id)
pair_state(low_id,high_id,policy_version,match_generation); PK(low_id,high_id)
conversations(id PK,match_id UNIQUE)
exposures(viewer_id,candidate_id,last_seen_at); PK(viewer_id,candidate_id)Evolve a solution and explain each change
Read the diagram
Generate candidates / Query nearby eligible profiles and apply user preferences. / A spatial match does not establish mutual interest or consent.; Persist directed swipes / Store one decision per actor and target; detect the reciprocal like. / Two simultaneous likes can each miss the other without coordination.; Commit one match / Serialize a canonical pair or use a transactionally checked pair record; notify asynchronously. / Retries and stale recommendations still need privacy filtering.
Step 1: Generate candidates
Query nearby eligible profiles and apply user preferences. A spatial match does not establish mutual interest or consent.
Step 2: Persist directed swipes
Store one decision per actor and target; detect the reciprocal like. Two simultaneous likes can each miss the other without coordination.
Step 3: Commit one match
Serialize a canonical pair or use a transactionally checked pair record; notify asynchronously. Retries and stale recommendations still need privacy filtering.
Responsibility overview
Read the diagram
User A to Swipe API: directed like; Swipe API to Pair DB: serialize canonical pair; User B to Swipe API: reciprocal like; Pair DB to Match worker: committed match intent; Match worker to Pair DB: check block policy; Swipe API to Candidate index: eligible profile candidates
Worked end-to-end scenario
User A likes B while B likes A from another region. Canonicalize the unordered pair as (min ID, max ID), route pair decisions to one owner, and record both directed likes. When both likes exist, a unique match row is created once and an outbox schedules notifications. A repeated swipe returns the stored decision. If a block arrives before the notification worker runs, the worker and chat admission must apply the block policy. Discoverability and matching are different paths: a cached profile recommendation is not permission to message someone.
Why these access paths matter
Index candidate profiles by coarse location cells and eligibility filters, then refine by actual distance. Swipe lookup uses actor and target; match uniqueness uses the canonical pair. Hide blocked users during candidate generation and result serving. Exact location exposure is unnecessary for distance filtering; return a product-appropriate approximate distance.
Build the baseline first
Read the diagram
Profile request → eligibility filter → nearby candidates; Swipe → durable pair state → mutual-like check; Unique match insert → outbox → notifications
- Profile request → eligibility filter → nearby candidates.
- Swipe → durable pair state → mutual-like check.
- Unique match insert → outbox → notifications.
Evolve the design under load
Read the diagram
Location updates → cell index → candidate cache; Pair-key routing → serialized mutual-like evaluation; Recommendation workers → precomputed bounded batches
- Location updates → cell index → candidate cache.
- Pair-key routing → serialized mutual-like evaluation.
- Recommendation workers → precomputed bounded batches.
Defend the hardest decision
A naive implementation writes A likes B, checks B likes A, and can miss a match if both transactions read before the other commits. Route both directions to a canonical pair owner, lock the pair row, or use an idempotent reconciler over durable likes. A unique canonical pair key prevents duplicate matches but does not by itself guarantee that a match is eventually discovered.
Failure and recovery analysis
A profile is recommended just before that user blocks the viewer. Revalidate block and eligibility at interaction time; removing a cached recommendation later is insufficient. If match notification publication fails, the match remains visible from durable state and the outbox retries. Notification failure must not delete the match.
Security and privacy boundary
Protect precise location, enforce age and eligibility policies, and rate-limit automated scraping and swiping.
Interview follow-ups with reasoning
Question: How do you avoid repeatedly showing passed profiles?
Show answer and explanation
Answer: Store exclusions and define whether they expire.
Question: How does a popular profile affect partitioning?
Show answer and explanation
Answer: Separate profile read caching from writes keyed by actor or canonical pair.
Question: What is the location privacy boundary?
Show answer and explanation
Answer: Return coarse distance bands rather than exact coordinates.
Operate and verify the design
Recommendation latency, mutual-like reconciliation lag and duplicate-match attempts.
Commit reciprocal likes concurrently and verify eventual creation of exactly one canonical match.
A second scenario to test transfer
A likes B at 10:00, B likes A at 10:01, and the two requests hit different application workers. Each durable Like becomes visible; exactly one transaction wins creation of a canonical pair key. Both clients receive the same match ID. A retried request returns that identity rather than making a second match or notification.
Two opposite-like requests race. How do you create one match and prevent repeated notifications?
Show answer and explanation
Answer: Lock or route both directed actions through the canonical pair authority. Under that authority, persist the unique actor-target Like, read both directions, and insert the unique match and outbox event when mutual. Independent read-after-write checks can miss both concurrent Likes; a unique match constraint alone only prevents duplicates. Recheck blocks before notification and chat admission.
Compare alternatives
| Decision | Benefit | Trade-off |
|---|---|---|
| Coarse candidate pool | Fast discovery | Stale or duplicate candidates |
| Exact final eligibility | Privacy and filters | Read-path checks |
| Canonical pair key | Single mutual match | Pair ordering and retries |
| Exposure cursor | Less repetition | Per-viewer state volume |
A design-changing exercise
Both reciprocal checks return absent before either swipe commits. What prevents a missed match?
Show answer and explanation
Answer: A serialized pair decision or transactional retry/reconciliation on the pair is required. Independent read-then-write checks do not guarantee detection.
Design workshop: serialize the pair, not the whole population
Discovery, swipe, match and authorized chat are core; sophisticated recommendation-model training is an extension. Assume discovery p95 under 300 ms, pair decisions under 200 ms within their home region and no chat admitted after a block is authoritative. Exact locations are not returned to users.
The pair key is ordered(low_user_id,high_user_id). Create pair_state with this primary key using an insert-on-conflict, then lock it before changing directed likes. This is important: locking a row that does not yet exist is not a mutual-exclusion mechanism. Both directions use the same authority and transaction.
BEGIN;
INSERT INTO pair_state(low_id,high_id) VALUES (:low,:high)
ON CONFLICT DO NOTHING;
SELECT * FROM pair_state WHERE low_id=:low AND high_id=:high FOR UPDATE;
-- Verify block/account state under the chosen pair policy.
-- Persist the direction's Like or Pass and stable request result.
-- If both directions now Like, insert one unique match and its outbox.
COMMIT;If A and B like concurrently, the first holder persists one Like; the second sees it after acquiring the pair lock and creates the match. A unique match row alone prevents duplicate matches but cannot make independent read-before-commit checks discover a missing one. A reconciler scanning durable pair changes is still useful repair, not a substitute for explaining the chosen concurrency rule.
Read the diagram
Like B; create/lock canonical pair; Like A; wait for same pair lock; Commit A's Like; no match yet; Read A's committed Like; commit match M; Outbox M; retry uses stable match identity; Recheck current block policy before notify
A block command locks the same pair record and increments its policy version. Candidate caches may still contain the profile, but response filtering and chat admission consult the current block/account policy. Notification after a block suppresses content rather than treating an old match event as permission. An unmatch closes the existing match; whether future reciprocal Likes can create a new match is a chosen generation policy. For this scenario require explicit new Likes after unmatch; do not replay old Likes into a new chat.
Discovery uses coarse cells and eligibility filters, fetches a bounded candidate pool, computes exact distance internally and ranks by declared preferences. Store exposure(viewer_id,candidate_id,last_seen_at) or a bounded recent-exposure set to reduce repeats. A signed discovery cursor pins a pool/version; an exact location never belongs in that cursor. Pass records expire only under a stated rediscovery policy.
Read the diagram
Command / Durable identity / Rejected case; Swipe / Actor/request -> decision and pair version / Changed payload under same key; Mutual match / Unique canonical pair + match generation / Blocked or disabled account; Start conversation / POST /matches/id/conversation -> stable conversation ID / Caller not an active matched participant; Send message / Conversation/sender/client-message identity / Match closed or current block denies admission
Add matches(match_id,pair_key,generation,state) and conversations(match_id UNIQUE,id). Chat storage/streaming can reuse a conversation design, but every send still checks active participant authorization. Do not duplicate all messaging infrastructure in this chapter; clearly state the contract between matching and messaging. Regional writes route to the pair's home shard; failover fences the old writer before another owner accepts commands.
Exercise: Both Likes commit on independent workers without either seeing the other. Is UNIQUE(pair) sufficient?
Show answer and explanation
Answer: No. There may be no attempted match insert. Route or lock the canonical pair as above, or provide explicit eventual reconciliation over both durable Likes. The first solves the primary race; reconciliation repairs missed processing.
Candidate discovery and current eligibility
A bounded candidate pool excludes recent exposures and rechecks current blocks and account eligibility before ranking.
Read the diagram
Coarse geo index fills a bounded candidate pool → Exposure filter removes recently shown candidate IDs → Hydrate current blocks, account state and eligibility → Rank eligible candidates; return a signed pool cursor → Cursor reveals no precise location; it is not authorization → Miss or stale candidate: bounded refill and policy recheck
Requirement trace and verification
| Requirement | Implementing design block | Verification link |
|---|---|---|
| R1 — Complete the primary user journey within the stated scope. | P01–P04; P09–P10. | V1 — Exercise the successful journey and the excluded/boundary case stated in the scope. |
| R2 — Preserve the problem's authoritative data invariant under concurrency. | P05–P06; P11–P12; DD1. | V2 — Run the race/replay case below and assert the invariant at the durable authority. |
| R3 — Meet the declared scale and API behavior without unbounded work. | P05–P08; P13–P14; relevant overload deep dives. | V3 — Exercise the API errors/retry identity and recompute the workload assumption that drives partition or capacity. |
| R4 — Recover from the named failure without losing or duplicating the user-visible outcome. | P15–P16; deep dives; Operations contract. | V4 — Submit reciprocal likes concurrently and replay both events; produce exactly one match record and deduplicated notification intent. |
Operational contract
| Area | Decision and signals |
|---|---|
| SLIs | Candidate latency; stale-location fraction; swipe conflict rate; match reconciliation lag; duplicate notification intents. |
| Overload limits | Bound candidate pages, geo-cell expansion, recommendation workers, and notification fanout. |
| Recovery | Replay swipes by request identity and rebuild match projection from canonical pair decisions. |
| Access controls | Enforce blocks, consent, profile visibility, and location precision at the authoritative eligibility boundary. |
| Dominant cost | Geo-index updates, recommendation compute, and media delivery. |
Senior-level interviewer follow-ups
Question: Two users like each other at the same time in different regions. How do you create one match?
Show answer and explanation
Answer: Route both actions to a canonical pair owner or use a unique ordered pair key with a transaction. Match creation is idempotent and records the pair generation; geo lookup is not the authority.
Question: A user blocks someone after cards were prefetched. What must the read path do?
Show answer and explanation
Answer: Filter blocks and current visibility again when serving the card or match. Asynchronous card cleanup improves efficiency but cannot be the authorization boundary.
A 60-second design answer
I would use geo search only to generate eligible candidate cards, then filter blocks, distance, and exposure policy. Likes are durable idempotent commands. A canonical ordered pair serializes mutual-like creation and produces one generation-scoped match; chat authorization checks that current match. I would monitor stale location, duplicate match attempts, block propagation, and candidate pool quality.
Related concepts to revisit
Technical references
PostgreSQL transaction isolation and concurrent updates.
Separate directional intent from the canonical match
Store A→B like and B→A like as directional intents. A concurrent pair of transactions may both discover the reciprocal like; normalize the match key as (min(A,B),max(A,B)) and enforce one unique match at its owner. Notification is an outbox/derived effect with its own replay protection.
swipe(A,B)=like; swipe(B,A)=like
canonical pair=(A,B)
first match insert -> m7
replayed/concurrent insert -> existing m7Read the diagram
swipe(A,B)=like; swipe(B,A)=like; canonical pair=(A,B); first match insert -> m7; replayed/concurrent insert -> existing m7
The discovery stack prunes by region/distance/preferences and then removes already considered or currently ineligible profiles. A Bloom filter can reduce exact checks, but a positive may be false; decide whether hiding a candidate is an acceptable approximation or verify it. Current blocking/privacy wins over an old precomputed stack. If matching is sharded, colocate the required pair decision or define coordination; two independent owners cannot claim local uniqueness implies global uniqueness.
Show answer and explanation
Answer: A second match row or notification is not necessary when both likes arrived. Reuse m7 and its notification identity. An approximate seen filter cannot authorize a match or replace the two authoritative intents.
Decision review: Tinder
Tinder: What it is
A discovery/matching exercise selects eligible profiles and records directional likes separately from a canonical mutual match.
Tinder: Why it is needed
Two workers can observe reciprocal likes and both try to create the same match; cached candidates may also become blocked.
Tinder: When to use it
Use a canonical unordered pair identity when one logical mutual match must exist; keep precise location protected in discovery interfaces.
Tinder: How to use it
Persist each authorized directional intent, atomically enforce unique pair creation and recheck applicable block/eligibility policy at interaction and messaging boundaries.
Tinder: Compare an alternative
A strongly serialized pair owner makes the winner clear but adds coordination. An asynchronous projector needs idempotency, bounded lag and explicit visibility semantics rather than assuming immediate mutual recognition.
Tinder: Worked decision exercise
The following inputs and policies are original exercise assumptions; they are not measurements or undisclosed company behavior.
A likes B and B likes A on different workers. Both attempt pair(A,B); one canonical match m7 wins. A retry returns m7. A later block must prevent the disallowed interaction even if an old profile card remains on screen.
Read the diagram
Like A to B and like B to A are distinct intents; Both workers target canonical pair(A,B); One match m7 is created; retries reuse m7; An old candidate cursor does not override a block
Can a signed candidate cursor be treated as permanent permission to like or message that profile?
Show answer and explanation
Answer: No. It identifies browsing state under its expiry policy, not current authorization. Apply current policy to the action, and avoid exposing exact location through the cursor or error behavior. Reconcile projections without recreating a blocked match from a stale event.
Tinder: Check the design
Observe canonical-pair conflicts, candidate freshness, block propagation and exposure duplication. Test reciprocal likes concurrent with a block under the chosen ordering rule.
Extension: Relationship lifetimes and current interaction authority
Start with canonical-pair serialization and bounded discovery. This workshop adds directed revisions, explicit renewed intent after unmatch/block, conversation lifetime and honest disclosure/location boundaries.
Deep dive: a historical match is not current consent
The baseline already serializes reciprocal likes at a canonical pair owner. This workshop makes repeat interactions, unmatch/block races, chat admission and privacy-preserving discovery explicit. These are original product policies for an interview exercise, not a description of Tinder's internals. Ranking and approximate location can be stale; permission to create a new interaction cannot inherit that staleness silently.
Give directional intent and relationship lifetime separate versions
Use canonical pair (min user ID, max user ID) as the serialization domain. Each direction has decision revision; the pair has a non-reused relationship epoch, owner epoch, policy version, current block flags and optional active match. A match and its conversation carry the relationship epoch. A new swipe includes actor, target, expected relationship epoch, expected directional revision, decision and actor-scoped request ID. Store a canonical payload fingerprint and receipt with the transition.
pair(low, high, owner_epoch, relationship_epoch, policy_version, blocks, active_match); PK(low, high)
direction(pair, actor, relationship_epoch, revision, decision)
match(id UNIQUE, pair, relationship_epoch, state); UNIQUE(pair, relationship_epoch)
command(actor, request_id, payload_hash, historical_result)
conversation(id, match_id UNIQUE, relationship_epoch)
message(conversation_id, actor, request_id, payload_hash, accepted_sequence)Within an epoch, a fresh expected-revision command changes only its direction. Revision 2 Pass prevents a delayed new revision-1 Like from restoring old intent. A compatible retry of an already accepted revision-1 Like returns its historical receipt without applying it again. Resolve the receipt before treating its old epoch/revision as a fresh command, while current access still gates any response disclosure. A same-key changed target, decision or expected version conflicts. Never generate a fresh request ID merely to recover an unknown accepted swipe.
The exercise forms one match when both current-epoch directions are Like and current policy allows it. Create match identity and notification intent in the same pair transaction. Discovery evidence or exposure IDs do not authorize a swipe; revalidate current interaction policy. A visible profile card is neither mutual consent nor a current conversation capability. Once a match is active, this exercise rejects fresh discovery-swipe mutations for that pair; use explicit unmatch or block to close it. A new Pass is not a substitute for the declared relationship-closing command.
Work unmatch, fresh likes and unblock by hand
At relationship epoch 7, A's revision-1 Like commits, then B's Like creates match M7. A unmatches. The authority closes M7, retires its conversation for new sends, increments relationship epoch to 8 and clears both directions. Old accepted command retries still resolve to their historical results, but M7 is inactive. Old-generation notifications and queued new swipe commands cannot create M8.
A explicitly reads epoch 8 and sends a new Like. That alone cannot rematch using B's old epoch-7 Like. B must also make a new intentional epoch-8 Like. Then one M8 and a distinct conversation can form. A client cannot silently take an old queued Like and replace its epoch with the new value; that would manufacture the fresh intent the policy requires. If a user wants to retry after an epoch conflict, show the current state and require the stated renewed action.
Block is also a pair-authoritative transition. A block closes any active match, clears directions, increments relationship epoch and policy version, and denies new interactions in both directions under this policy. Unblock changes policy and increments the epoch again while leaving directions empty; it does not restore an old match, likes or conversation. Unmatch is available only to a participant in the current active match, so a delayed M7 unmatch cannot close M8. Administrative account restrictions need the same current authorization contract; asynchronously copying account state into pairs alone cannot promise immediate global enforcement. Use a supported shared authority, current entitlement check or explicitly bounded policy grant and disclose its availability cost.
Read the diagram
Unmatch closes relationship M7 → Epoch 8 clears both directional likes → An old Like retry stays historical → Two explicit epoch 8 likes create M8 → Old conversation cannot admit new messages
Serialize chat admission and publication with the relevant authority
Suppose B submits a message while A blocks B. If block commits first, reject a new message under old M7. If message acceptance commits first, retain its accepted history/receipt; the later block prevents subsequent admission and any newly authorized disclosure forbidden by policy. Block cannot erase text already delivered or downloaded. A lost accepted reply is not a reason to append the message again under a new key.
A check at the matching service followed by an unrelated chat-store write leaves a race. Choose a concrete boundary: in this exercise, the pair owner appends message admission and stable publication intent to its durable ordered log while checking current match/epoch/policy. A chat store consumes accepted records idempotently by conversation/message identity; it cannot independently admit messages using a cached match. A different design could coordinate a shared transaction or use explicitly bounded grants, but must not claim an asynchronous check gives immediate block enforcement.
Content retrieval and notification dispatch perform their own current-policy checks, not just event-generation checks. A notification worker seeing M7 after unmatch must suppress the obsolete disclosure rather than reinterpret it as M8. Rejoin/rematch does not automatically expose old conversation history. Define permitted history by conversation generation, current participant access and retention policy. If an external push provider accepted content before a block, reconcile the original delivery; creating another push or assuming recall is not valid recovery.
Keep interaction receipt and current view separate in the API. A successful old Like receipt can identify its historical revision without declaring the match still active. To avoid block-status disclosure, return a generic unavailable/currently-ineligible view according to the product policy rather than revealing the other party's private block reason. Internal audit may retain detailed cause under restricted access.
Bound discovery without turning distance into an oracle
Geo indexing generates a bounded candidate pool, then current preference/account/block and exposure filters decide serving eligibility. Use viewer-bound, expiring cursors that bind ranking/candidate generation and advance over filtered entries. Bound examined candidates, distance calculations, feature calls and page work. If current filtering removes everything within that budget, return a partial/empty eligible page honestly instead of retrying an unbounded search or returning blocked profiles to fill a quota.
Protect exact coordinates on storage, logs, exports and error paths. Coarse distance buckets alone do not prove location privacy: repeated queries from controlled positions can narrow a person's location. Apply query/rate controls, sufficiently coarse/limited responses and an explicit threat model; avoid revealing exact cells, candidate rejection reasons or precise update times. A blank page cannot prove no nearby users. Retain exposure and location data for a declared finite purpose/horizon rather than logging unlimited movement histories.
Assume 500 million swipes/day: about 5,787/s average and 28,935/s at fivefold peak. At 100 bytes each, raw swipe history is 50 GB/day before replication and receipts. At peak, three durable records per decision imply roughly 86,805 records/s; that is a write-amplification estimate, not three times the number of independent consent decisions. A page examining at most 200 candidates at 1,000 pages/s can demand 200,000 eligibility checks/s before cache/aggregation savings. All current-policy dependencies must fit that budget.
A 600,000-event notification/materialization backlog with 5,000/s processing and 3,000/s fresh arrivals needs at least 300 seconds to drain. Old notifications still require current-generation checks during catch-up. Bound slow gateways, per-pair message queues and globally shared admission; no amount of candidate-cache replication increases the serialization capacity of one abusive pair. Monitor stale-epoch rejection, mutual-like-to-match lag, blocked-interaction rejection, old-notification suppression and privacy-safe candidate exhaustion.
Matching assessment: prove the interaction belongs to this lifetime
Question: After M7 is unmatched, A retries the accepted Like that helped create it. Does that count as one of the new likes required for M8?
Show answer and explanation
Answer: No. Return permitted historical receipt evidence without mutating epoch 8. Both directions need new explicit epoch-8 intent; a current-looking card, automatic retry ID or client-rewritten epoch cannot substitute for it.
Question: Is a current-match read followed by a separate chat insert enough to prevent sends after a block?
Show answer and explanation
Answer: Not under the immediate admission contract. Block can commit between those actions. The exercise serializes acceptance with pair policy and durably publishes that accepted message identity; retrieval and dispatch separately enforce their current disclosure policy. Already delivered bytes cannot be recalled by changing a row.
Question: A page contains only blocked or expired candidates. Can the server continue searching until it finds twenty, or expose exact distance to improve ranking?
Show answer and explanation
Answer: Neither is an automatic consequence of the requirement. Bound candidate work and return honest partial results. Keep exact coordinates out of responses and recognize repeated-query inference; define rate, precision and current-policy controls rather than claiming bucketing alone guarantees privacy.
Score one point each for directional revision/relationship/owner identity; historical receipts versus fresh post-reset intent; block/unmatch/chat authority and disclosure ordering; scoped bounded discovery and location threat model; finite write/fanout/recovery evidence. Reusing old likes for M8 or admitting chat through a stale match check is a critical failure. Repair the pair state machine, then retest with unblock, an obsolete unmatch request and a push accepted just before block.
Two opposite-like requests race. How do you create one match and prevent repeated notifications?
Your design draft
Clarify assumptions, explain your approach, and test the difficult cases. Save your draft, then compare it with the study notes.
Self-review checklist
Self-guided practice. Automated AI feedback and code execution are not connected.