All posts
System Design Mastermind · Part 34
  • System design
  • Interview prep
  • AI/ML systems
  • Trust and safety
  • Classifiers

Content moderation pipeline system design: hash matching, classifiers, LLM checks and human review at a billion items a day

How to design a content moderation pipeline (posts, images, video and chat) in real interview order: items per second, prevalence, LLM calls and reviewer-hours as the numbers that matter, a moderation API with a time budget, decisions as events, reports and appeals, an explainer on perceptual hash matching, hash lists, classifiers, an LLM policy check, a decision engine with two lines per policy, a priority review queue and a decision log built in passes, one meme walked from upload to removal, copies, an appeal and a new model, a lab on thresholds, base rates and the review band, a lab on reach and the review queue over a day, evals, LLM judges, shadow and canary rollouts, cost per tier, prompt vs fine-tune, guardrails, and what happens when each part fails.

27 Oct 2026 · 34 min read · interactive

Share

The 1-minute answer

Content moderation is a cascade that spends the most effort on the fewest items. Every product calls one moderation API with the item and its context. At upload the media is hashed and matched against lists of known violating items (a near-copy is a few bits away, so a match is a small Hamming distance). Small classifiers score every policy in tens of milliseconds, and a decision engine applies two lines per policy and surface: above the remove line act automatically (or hold before publishing for the most severe), below the review line allow, and in the band between publish and get a second look. The band goes to an LLM that reads the written policy, then to a review queue ordered by severity × predicted reach × likelihood, not by arrival. Every action comes with a reason and an appeal to a different reviewer, and every decision is logged with its model and thresholds version, which makes verdicts into training labels and bad changes undoable. New models and policies go golden set → shadow → canary with an action-rate breaker before they act on anyone.

How this page follows the interview

Each phase is a section below, in the order you'd present it. Click a phase for what to say, what to write, and the trap.

✅ Seen: said publicly (cited)🔶 Inferred❓ Unknown: state it as an assumption🧭 Interview choice

Queues and priority are in Foundations F10, security and abuse in F15, LLM inference in F18. The offline re-scan of old content is the batch pipeline in Part 31. Designed from public material only: no employer's internal systems.

Requirements and numbers

Agree the content types, surfaces and policies, then size items per second, how many reach the LLM and people, and how many mistakes a day. Change any input: each number comes with the decision it forces.

Functional

  • Check posts, comments, images, video and chat against written policies
  • Act: allow, hold, limit, warn, remove, strike, suspend, report to authorities
  • Users report content; creators get a reason and can appeal
  • Reviewers work a queue with the context and tools they need
  • Policy teams change rules and thresholds without a deploy

Non-functional

  • Pre-publish checks within ~150 ms; the rest within minutes for viral items
  • High precision on automatic removals; recall measured per policy
  • Fair across languages and regions; measured, not assumed
  • Every decision auditable and explainable (EU DSA, India's IT Rules)
  • Legal orders acted on within their deadline (3 hours in India)

Out of scope (say it)

Writing the policies themselves, spam and fake-account detection as a separate system, ads review, copyright matching, and end-to-end encrypted chat (no server-side content to scan).

Capacity calculator

Every input is an assumption 🔶: say it out loud. Volumes, shares and prices are round teaching numbers, not any company's ❓. For scale: Roblox reported 6.1 billion chat messages a day and as little as 0.01% of 2024's content violating ✅ Roblox Jul 2025

Three rules for this estimate
  1. Every item pays the cheap tiers: peak items/s sizes hashing and small models.
  2. Each tier sees ~100× fewer items than the one before: the shares sent to the LLM and to people set the bill.
  3. Mistakes scale with volume: harmless items × false-positive rate = wrong removals a day.
They'll push on thisAnswer out loud, then open.

Core entities and the API

An item is judged; signals are evidence; a decision is what happened and why. What they listen for: a sync check with a time budget, later decisions as events, reports and appeals, and a reason with every action.

EntityKey fieldsNote
Request
Response

How a hash match works

A cryptographic hash changes completely if one pixel changes. A perceptual hash like PDQ turns a photo into 256 bits so that similar photos get similar bits, and a match means at most ~30 bits differ. Pick an edit, or set the bits yourself.

What the tests showed

  • Size and threshold: 256 bits; unrelated photos differ in ~128 on average; the authors treat ≤ 30 as a confident match. ✅ Dalins et al. 2019
  • Survives: format changes (99.96% within the threshold), resizing, and small text (mostly under 10 bits). ✅ Dalins et al. 2019
  • Breaks: crops over ~5% and rotations over ~5° push past it; an opaque watermark missed about half. ✅ Dalins et al. 2019
  • At scale: Meta blocked 1.2 million of 1.5 million copies of the Christchurch video at upload in 24 hours, and added audio matching for screen recordings. ✅ Meta Mar 2019

The edit buttons use rounded, typical distances read from those tests; your images will vary 🔶. Random photos almost never collide; the real risks are near-uniform images (PDQ reports a quality score to skip them) and deliberate crops and filters.

They'll push on thisAnswer out loud, then open.

High-level design

Build it in passes and say why each box exists. Click any box to see what it does, what it owns, what's inside it and what you'd watch.

They'll push on thisAnswer out loud, then open.

Walk one post, box by box

On a Saturday evening a creator with 80,000 followers posts a meme: an image with a Hindi-English caption. Each step lights up the path and shows what goes over the wire, what's stored and how long it takes, including the copies, an appeal and a new model shipping.

On the wire

Arrows show who calls whom, and the numbers give the order. Replies go back along the same line.

What keeps it fast and cheap

A demo calls one model per post. These six details are what turns it into a pipeline that keeps up with a billion items a day.

    Data and database choices

    Decisions are history, not a status field. Hash lists live in memory, signals stream as events, review tasks sit in a priority queue, and every decision is appended to a log with the versions that made it.

    DataPickConsideredWhy not those

    The one thing to know: the decision engine

    # Decision engine. Illustrative; names made up.
    def decide(item, scores, ctx):
        if hash_match(item.media):        # ≤ 30 bits
            return act("remove", "hash")
        for policy, s in scores.items():
            L = lines[policy][ctx.surface]   # versioned
            if s >= L.remove and policy.severe:
                return act("remove", policy)  # breaker-guarded
            if s >= L.hold and ctx.sensitive:
                return hold(policy)          # not shown yet
            if s >= L.review:
                queue(item, policy, priority=
                    severity(policy) * reach(item) * s)
        return allow()

    Illustrative. The lines live in versioned config per policy and surface, so policy teams change them without a deploy. 🧭

    Why log every decision

    1. Appeals need the why: the rule, the signals and who or what decided. ✅ DSA Art. 17
    2. Undo needs the version: a bad model's removals are found by model@version, not by guessing. 🧭
    3. Training needs labels: reviewer verdicts and appeal outcomes train the next model. ✅ Meta Aug 2020
    4. The law needs records: EU statements of reasons; US child-safety reports preserved for a year. ✅ DSA · 18 U.S.C. 2258A

    More database questions

    They'll push on thisAnswer out loud, then open.

    Deep dive: thresholds, base rates and the review band

    A classifier gives a score, not a decision. Harmless items outnumber violating ones hundreds to one, so a score that looks confident can still be wrong most of the time. Two lines per policy trade wrong removals, misses and reviewer headcount. Pick a preset, then move the lines.

    Harmless scores ~ N(0, 1), violating ~ N(d′, 1); scores are calibrated probabilities at the prevalence they were fitted on. Red zone: removed automatically; apricot band: sent to people; left of it: allowed. Teaching model, not any company's classifier. 🔶

    The rules this lab teaches

    1. Precision depends on prevalence; AUC doesn't. A 99.8%-AUC model removing at 0.5 is right 89% of the time here. 🔶
    2. The remove line goes high (0.97+ here) and only for policies where a miss is worse than a wrong removal. ✅ Meta Jan 2025
    3. The band is a staffing number: moving the review line from 0.05 to 0.01 needs ~2.4× the reviewers. 🔶
    4. Recalibrate when the mix changes: a 20× drop in prevalence takes 0.97 from 99% right to 88%. 🔶

    Real numbers to quote

    Meta (Jan 2025): of the millions of pieces of content it removed each day, "one to two out of every 10 of these actions may have been mistakes"; it raised the confidence needed to remove, and by May 2025 reported ~50% fewer enforcement mistakes in the US with prevalence largely unchanged. ✅ Meta 2025

    Roblox (Jul 2025): AI is deployed only when it beats humans at scale on both precision and recall; its voice classifier runs at a 1% false-positive rate. ✅ Roblox Jul 2025

    Off the shelf: Llama Guard 4 reports 69% recall at 11% false positives on English text in Meta's own test. ✅ Llama Guard 4 card

    They'll push on thisAnswer out loud, then open.

    Deep dive: reach, speed and the review queue

    Harm is views, and most views come early. A queue that's 85% busy on average still backs up for hours at the evening peak, so what you review first matters more than how fast you review. Top: flagged items an hour against what reviewers clear. Bottom: how long an item flagged at each hour waits. Pick a preset, then change the switches and numbers.

    A 5-minute fluid model of one day in steady state (peak at 21:00), FIFO within each lane; views follow a half-life after posting. Rounded teaching values. 🔶

    Three rules, in order

    1. Order by expected harm: severity × predicted reach × likelihood, not arrival time. ✅ Meta Aug 2020
    2. Staff for the peak, not the average: at 85% average load the evening backlog lasts hours. 🔶
    3. Short-lived content needs action before review: hold the top band, or act automatically on confident hits. 🧭

    Numbers to quote

    Meta ranks content for review by "virality, severity of harm and likelihood of violation", removes directly when nearly certain, and sends the rest to people. ✅ Meta Aug 2020

    Roblox reported a median time to action of ten minutes on notices of illegal content, and voice moderation within 15 seconds. ✅ Roblox Jul 2025

    India cut the time to act on government and court orders from 36 hours to 3, in force from 20 February 2026. ✅ IT Rules 2026

    They'll push on thisAnswer out loud, then open.

    Deep dive: evals, LLMs, rollouts, cost and guardrails

    A moderation model fails quietly: a bad version removes a million posts without a single error log. Prove each change at the thresholds you'll run, on every language, before it acts, and keep machines from doing irreversible things alone.

    The release ladder

      Cost per day: cheap checks for all, expensive for few

      $0.40 per 1,000 LLM checks is the calculator's 800 tokens at $0.50 per million. All prices are round teaching numbers, not quotes ❓. Batch the LLM calls and cache the policy prompt as a shared prefix (Part 31) to cut that tier further.

      LLMs as moderators and judges: useful, with limits

      A policy prompt, a fine-tuned classifier, or both?

      Tick what's true for the policy.

      Cost and latency per item

      1. Cheapest first: hash lookup, then small models; each tier sees ~100× fewer items. 🧭
      2. Distil and quantise: large models teach small ones for the hot path. ✅ Roblox Jul 2025
      3. Free first tier: OpenAI's moderation endpoint is free, text and images, 13 categories. ✅ OpenAI docs
      4. Cache by hash: a re-upload reuses the first verdict; no model runs twice on the same media. 🧭
      5. Spend people last: the band size, deduped reports and LLM pre-checks are the biggest cost levers. 🔶

      Guardrails on the moderation system itself

      1. Automatic removal only where it's earned: high-severity, high-precision policies; less severe ones act after a report. ✅ Meta Jan 2025
      2. An action-rate breaker per policy and language: review instead of remove when rates jump. 🧭
      3. People for irreversible actions: account bans, legal reports; appeals not decided solely by machines. ✅ DSA Art. 20
      4. Protect reviewers: blur and greyscale by default, exposure limits, rotation off severe queues. 🧭

      Regression tests for policies and models

      1. Golden set in CI: every model, prompt or threshold change runs it per slice; a slice that drops fails the build. 🧭
      2. Pinned cases: every overturned appeal and every missed viral item becomes a test with its answer. 🧭
      3. Counterfactual pairs: the same sentence about different groups, or in different dialects, should get the same verdict. 🧭
      4. An adversarial set: misspellings, code words, crops; Roblox describes AI-assisted red teams building such data. ✅ Roblox Jul 2025
      They'll push on thisAnswer out loud, then open.

      An item's lifecycle

      Every item moves through a small state machine. Click events to move it; ones that can't happen from the current state are disabled. Each event shows what fires across the system.

      NormalSomething was wrongGreyed out: not possible from the current state.

      Edge cases interviewers love

      They'll push on thisAnswer out loud, then open.

      Failure, monitoring and recovery

      Moderation fails loudly (posting stops) and quietly (a model over-removes in one language, or harmful posts wait in a queue). The quiet ones matter more. Click a box to take it down: red is the failed part, amber is its blast radius. Each answer covers impact, degraded mode, the alert, automatic and manual recovery, and how you'd trace it.

      Tracing it back: a viral lane vs a FIFO evening

      Every span carries content_id, policy, model and thresholds versions. Times are from the upload; illustrative. In the bad trace the LLM check times out, users report it, and the task waits behind 41,000 others.

      How one failure becomes three

      What you'd alert on (SLOs)

      SignalTargetAlert

      Incident playbook

        The toolkit

        Name the technique, then say where it goes in this design.

        They'll push on thisAnswer out loud, then open.

        Making it fast, and who owns what

        The pre-publish path is milliseconds; everything after it is minutes of queue and seconds of judgement. Bars are sizing estimates, not measured figures.

        TeamOwnsPaged when…

        Senior follow-ups beyond the happy path

        Interviewers pick from these themes once the design is on the board. Have one concrete answer per theme, tied to this design.

        Practice ladder

        Real interviews go level by level. Answer out loud before opening each one. Levels 6–7 are where Senior becomes Staff.

        Sources

        Checked October 2026. Company figures are as published: Meta's January 2025 post (one to two in ten enforcement actions may have been mistakes, a higher confidence bar, multiple reviewers, LLM second opinions) and its May 2025 update (~50% fewer US enforcement mistakes), Meta's Aug 2020 post on ranking review by virality, severity and likelihood, its Mar 2019 Christchurch update (1.5 million copies removed, 1.2 million blocked at upload), its Dec 2021 Few-Shot Learner and Dec 2022 Hasher-Matcher-Actioner posts, and Roblox's Jul 2025 moderation post (6.1 billion chat messages a day, 750K+ requests a second on text filters, distillation, 80% labeler alignment). PDQ's behaviour is from Dalins, Wilson and Boudry's 2019 test. LLM moderation is from OpenAI's Aug 2023 post and moderation docs, Meta's Llama Guard 4 card (via NVIDIA, Apr 2025) and Zheng et al. (2023). Law is the EU DSA (Articles 17 and 20, transparency database docs), India's IT Rules amendment (notified 10 Feb 2026, summarised by Hogan Lovells), 18 U.S.C. § 2258A and NCMEC's 2024 numbers. The labs use rounded teaching values and a textbook score model, and say so. Techinterview.org is a third-party prep site, used only to cross-check what interviewers expect. Nothing here comes from any employer's internal systems.

        System Design Mastermind · AI / ML systems

        Series home

        All of AI / ML systems

        8 published · 1 comingLLM and ML systems, where interviews are heading.

        22

        LLM serving platform system design (ChatGPT-style): tokens, GPUs and safe model changes

        Chat API (auth, token limits, history, safety, SSE with resumable event ids) → router picks model (easy turns to a small one), version (registry canary split) and a replica with the prefix cached → vLLM-style engines batch continuously up to the time-per-token target. Admit by priority because GPUs take minutes to add; ship every model change through evals, shadow and canary, with rollback by one number.

        34 min · interactive Preview
        25

        RAG assistant over company docs system design: retrieval, permissions and answers you can trust

        Ingestion (change events + full sync → parse → chunk with a context line → embed only changed chunks) fills a versioned index of keywords, vectors and allowed principals. Serving rewrites the question, runs hybrid search with the permission filter inside it, reranks 150 → 8, answers only from numbered sources, checks grounding and re-checks cited docs. A golden set gates every change.

        34 min · interactive Preview
        28

        AI agent platform system design: tools, durable runs, approvals and agents you can trust

        A durable orchestrator runs each agent as workflow code: pin the version, call the model through a caching gateway, record every step so crashes resume. The model only proposes tool calls; a tool gateway validates, authorizes with the user's own token, adds idempotency keys and parks irreversible steps for approval. Budgets stop runaways; end-state evals with k tries gate every release.

        35 min · interactive Preview
        31

        Offline GPU batch inference system design: millions of LLM calls by a deadline, on GPUs that can vanish

        Validate the file, split it into ~20-minute shards, lease them to GPU workers on spot that load the model once and run hundreds of rows at a time with the shared prompt cached. Each attempt writes its own file; one conditional commit per shard makes output exactly-once. Golden set and canary shard gate every new version.

        34 min · interactive Preview
        34

        Content moderation pipeline system design: hash matching, classifiers, LLM checks and human review at a billion items a day

        Hash at upload against known-bad lists, score every policy with small classifiers in ~50 ms, two lines per policy: remove above, allow below, and the band between goes to an LLM that reads the policy, then a review queue ordered by severity × reach × likelihood. Every decision logged with a reason, appealable, and gated by golden set → shadow → canary.

        You're reading this Preview
        35

        Recommendation system design (TikTok-style For You feed): candidates, ranking, freshness and A/B tests

        Several sources (two-tower ANN search, like-your-likes, trending, a fresh pool) retrieve a few thousand items; a light ranker keeps a few hundred; a heavy multi-task ranker predicts finish, like, share and skip; a value model and re-rank add diversity, in ~200 ms. Events stream back to features in seconds and to incremental training in minutes; models ship via interleaving and A/B tests.

        34 min · interactive Preview
        36

        LLM evaluation and guardrails platform system design: judges, guard latency, paired eval gates and safe rollouts

        Every product calls an AI gateway: versioned config, input guards (PII mask, a small injection classifier, an LLM judge only when unsure), output guards on streamed chunks, a trace per request. Off the path: sampled traces judged online, people calibrating the judges, failures turned into regression tests, and every change gated by a paired eval with error bars, then shadow, canary and A/B.

        33 min · interactive Preview
        37

        AI coding agent system design (Claude Code, Cursor, Codex): context, edits, sandboxes and evals

        Three shapes, one backend: a small self-served Tab model per keystroke; an agent loop with a context engine (grep plus an optional index), a cached prompt to a frontier model, text-anchored edits or a fast apply model, permissions and an OS sandbox; and background agents in a container per task that open a PR. An eval harness gates every change on pass^k.

        34 min · interactive Preview
        ··

        Feature store and training platform

        Coming next

        More posts