LESSON 08 · Privacy and operations

Keep suggestions trustworthy

Treat bad suggestions, private data, and stale builds as operational failures.

SYSTEM VIEW

The suggestion path

Diagram view
Time—
Unsafe shown—
Snapshot—

Follow an unsafe phrase from its report at 09:00 to a snapshot that no longer holds it, then see what keeps search working when suggestions fail.

  1. Raw searches can hold names, phone numbers and medical worries. The Build policy admits a term only after, say, 100 distinct users search it. One person’s private query stays out, and so does a script submitting one phrase 50,000 times: it is still one user.

    Threshold
    100 distinct users
    Script
    50,000 searches, 1 user

    What changed

    • Eligible at 100 distinct users
    • Private query held
    • Script’s 50,000 searches held
  2. An unsafe phrase slipped through anyway and sits in snapshot v812. The Query API serves it in a public list, the Policy filter doesn’t block it yet, and at 09:00 a report arrives. Popularity is not proof of legitimacy.

    Reported
    09:00
    In
    snapshot v812

    What changed

    • Report at 09:00
    • Unsafe phrase in a public list
  3. A fast denylist in the serving path suppresses the suggestion within minutes. By 09:05 the phrase is on the Policy filter’s denylist, which removes it from every list on the way out. Snapshot v812 and the Term counts still hold it.

    Suppressed
    09:05
    Still in
    v812 and the counts

    What changed

    • Phrase on the denylist
    • Phrase stops appearing
    • v812 and counts unchanged
  4. The same day, the team adds the phrase to the Build policy and cleans it out of the Term counts. The serving filter alone hides the phrase but leaves it in the source data, waiting for the next build.

    Build policy
    phrase excluded
    Term counts
    aggregates cleaned

    What changed

    • Phrase excluded at build
    • Aggregates cleaned
  5. The next morning’s build reads the cleaned counts through the Build policy and writes snapshot v813. The team verifies that v813 omits the phrase. Had the source been left alone, the phrase would have come back with this build.

    New snapshot
    v813
    Phrase
    absent, verified

    What changed

    • Snapshot v813
    • Verified: phrase absent
  6. Monitoring watches what users feel and what builds deliver: keystroke latency, API p95 and p99, empty-result rate, cache hit rate, shard skew, build age, stream lag and policy-block hits. Test stale-snapshot fallback, shard failure, cache stampede and rollback before you need them.

    Users feel
    p99, empty results
    Builds
    build age, stream lag

    What changed

    • Monitoring on the API and builds
    • Drills: fallback, rollback
  7. The Query API goes down. The Client gives its “cam” request a short timeout and shows no list rather than block typing, and submitting the full search still works. Monitoring shows the failure, and a last-good snapshot gives the service something to fall back to.

    Client
    short timeout, no list
    Search
    still works

    What changed

    • Query API down
    • Client shows no list
    • Full search still works

Space plays · ← → step · Home resets

THE IDEA

How it works

Raw searches can reveal personal information: people paste names, phone numbers, and medical worries into search boxes. Minimize collection, limit retention and access, and remove sensitive or abusive terms before public ranking. One concrete guard is a threshold: a term becomes eligible only after, say, 100 distinct users have searched it, so one person’s private query does not surface. Resist manipulation with rate limits, abuse signals, and anomaly review; counting distinct users also blunts a script that submits one phrase 50,000 times. Popularity is not proof of legitimacy.

A fast denylist can suppress an unsafe suggestion now, while aggregate and future snapshot correction prevents its return. A typical sequence: a report arrives at 09:00; the phrase joins the serving filter by 09:05 and stops appearing; the team adds it to build policy and cleans the aggregates that day; the next morning it verifies the new snapshot omits it. Skipping the second half brings the phrase back with the next build.

Monitor keystroke latency, API p95/p99, empty-result rate, cache hit rate, shard skew, build age, stream lag, and policy-block hits. Test stale-snapshot fallback, shard failure, cache stampede, and rollback. If suggestions fail, full search submission should still work: give the request a short client timeout and show no list rather than block typing.

DECISION POINT

An abusive phrase is filtered now but reappears after the nightly build. What was missed?

Write a sentence or two to unlock the guidance. Committing first is what makes it stick.

Keep in mind

  • Immediate filtering and source cleanup solve different parts of removal.
  • A last-good snapshot and graceful empty list protect the primary search flow.
CHECK YOUR UNDERSTANDING

Put it into practice.

1 OF 3
ApplyQUESTION 01

A phrase containing someone’s home address appears as a public suggestion. What is the full response?

Choose an answer. You’ll see the explanation once you get it right.

Design address autocomplete for a delivery app

Apply prefix search to addresses and places, where location matters more than popularity and typos are routine.

The brief

Customers type a delivery address or a place name into a delivery app and pick from a short list. Suggestions must favor results near the user, stay within the correct country's data, and tolerate common typos. Choosing a suggestion must resolve to one stable place ID with coordinates, because a wrong pin means a failed delivery. Keep routing, pricing, and courier dispatch outside this exercise.

  • 10 million people use the app each day. Each runs 1.5 address or place searches a day, and each search sends 6 suggestion requests after debouncing. Use decimal units and 86,400 seconds per day.
  • Peak traffic is 5 times the daily average. The app serves 4 regions, and the busiest carries 40% of traffic and 40% of the catalog. Assume its peak lines up with the global peak.
  • The catalog holds 400 million addresses and 50 million places at about 200 bytes each, refreshed monthly from data vendors. Search structures take 3 times the raw size. A serving node has 64 GB of usable memory.
  • About 10% of requests contain a typo and need fuzzy matching, which costs 5 times an exact prefix lookup. A node handles 2,000 exact lookups per second.
  • Aim for p95 under 100 ms on the server. Text typed into the box can identify where someone lives, so treat it as personal data: do not put it in shared caches keyed to a person or in public ranking.

Reading a design isn’t the same as producing one under a clock. Try it timed: the requirement change stays hidden until partway through.

Loading your draft…

State your scope. Estimate average and peak request rates, the busiest region's peak, the extra CPU from fuzzy matching, and the index size and shard count for the busiest region. Keep units visible.

0 / 4,000 characters

Name the components and what each stores. Trace one suggestion request, one mistyped request, and the moment a person picks a result. Explain how location affects both ranking and any cache key.

0 / 4,000 characters

Choose a likely bottleneck and the evidence that would justify scaling it. Explain what users see if a region's serving tier or a new data build fails, and how they can still finish an order.

0 / 4,000 characters

Respond to the courier-report change below. Decide where new entries live until the next full build, how typo matching reaches them, and what stops a bad report from misdirecting deliveries.

The requirement changesCouriers can now report addresses the vendors do not have yet, such as a newly opened apartment tower or a corrected entrance. A verified report must be searchable in its region within 10 minutes, including with typos. Your monthly build alone no longer meets this. What changes, and what new failure can it introduce?

0 / 4,000 characters

Write an initial response in all four sections to unlock the checklist and two worked approaches.

Next chapter: YouTube

0 of 3 checkpoints answered correctly to complete this lesson.