System Design Atlas
LOCAL GUEST MODERead and practice without an account.

Your saved topics and reading progress stay in this browser. Sign in to sync supported profile and progress data.

Distributed Denylist for Request Blocking

A regional updater downloads a truncated snapshot.

● HardSystem 122 min2 prerequisites
My progress
Topic tools

Layout updated

Explore the design, then rehearse the decisions without looking.

Problem statement

Design a system that distributes IP blocking rules to request gateways. Gateways should block matching requests quickly and pick up changes to the rules safely.

Functional requirements

  • Import and update IP-address and domain blocking rules.
  • Allow or block requests using the installed rules.
  • Show each region's rule version and update age.

Non-functional requirements

  • Check requests locally in under 1 ms.
  • Propagate new rules within about 60 s in healthy conditions.

Back-of-the-envelope estimates

Illustrative estimate
1M rules × illustrative 64 bytes ≈ 64 MB raw

Entities

Entity / logical owner
Rule(sourceId, ruleId, , action, sourceGeneration)
(version, checksum, sourceCutoffs, artifactURI)
ActiveVersion(region, version, activatedAt)

API design

Operation / inputResponse and retry contract
PUT/sources/{id}/generation {generation, rules, signature}Reject malformed or regressing generations; stage a complete source replacement.
GET/snapshots/latestSigned with checksum and artifact version; notifications only accelerate discovery.
CHECK {clientIP}Local allow/deny with matched policy/version; address provenance must be trusted.

High-level design

How to draw this design

  1. Collect source rulesTrusted feeds, fetcher, and normalizer
  2. Build and publishCanonical PostgreSQL, builder, and S3
  3. Distribute versionsKafka notifications and regional updaters
  4. Enforce at the edgeGateway and in-memory matcher

Validate the rules, publish a complete , and atomically activate it at each gateway.

State ownership
PostgreSQL owns canonical rules. Gateways enforce a validated version.
Scale
Compile once and keep request-time matching local.
Correctness
Verify the complete before swapping the active version.
Failure and recovery
A missed notification triggers polling. An invalid leaves the last valid version active.
Distributed Denylist / Blocking
G src->fetch 1. Pass validated input fetch->db 2. ingest generation db->snap 3. latest rules snap->obj 4. artifact then manifest snap->notify 5. version ready obj->reg 6. download notify->reg 7. signal reg->matcher 8. atomic ref swap matcher->gw 9. allow / reject gw->matcher 10. check req->gw 11. Pass validated input src Gov / Trusted Sources compute fetch Fetcher / Normalizer compute db PostgreSQL / Canonical Rules DB state · durable snap Snapshot Builder compute obj S3 Immutable Snapshots state · durable notify → Kafka / Version Notifications messaging reg Regional Updaters compute matcher Redis / In-memory Rule Matcher state · memory gw Edge / Gateway edge req Incoming Requests compute
  • Compute
  • State
  • Messaging
  • Edge

━━ Synchronous┄┄ Asynchronous···· Recovery / control▧ Fault

Select a component or follow a numbered connection.

Each arrow is one interaction. Request, background and recovery branches are not one linear transaction.

Read the 11 flow steps

High-level design component walkthrough

External dependency

Gov / Trusted Sources

Publish IP / deny rules

Why, tradeoff and connected operations

Treat another system as a separate failure and retry domain with a documented contract.

Tradeoff: Inputs can be malformed/outdated

Connected operations: Pass validated input

Backend service

Fetcher / Normalizer

Fetch, validate, normalize source entries

Why, tradeoff and connected operations

Isolate this operation so it can scale and fail independently from storage.

Tradeoff: Source outages or format drift

Connected operations: Pass validated input; ingest generation

Relational database

PostgreSQL / Canonical Rules DB

Source-specific rules + generations

Why, tradeoff and connected operations

PostgreSQL holds canonical rules and version generations. Transactions preserve a consistent rule set while administrators publish changes. is useful for controlled rule edits; the request path uses a derived in-memory matcher instead.

Tradeoff: Generation storage / validation work

Connected operations: ingest generation; latest rules

Backend service

Snapshot Builder

Compile rules / test full version

Why, tradeoff and connected operations

Isolate this operation so it can scale and fail independently from storage.

Tradeoff: Build time delays urgent changes

Connected operations: latest rules; artifact then ; version ready

Object / blob storage

S3 Immutable Snapshots

Versioned artifacts + verified

Why, tradeoff and connected operations

Object storage distributes immutable rule snapshots with a checksum and version. Regions can download, verify and retain older snapshots for rollback. Snapshots are bulk artifacts, not a database or a replacement for the canonical rules.

Tradeoff: Download and storage replication cost

Connected operations: artifact then ; download

Queue / event stream

Kafka / Version Notifications

Tell regions of new

Why, tradeoff and connected operations

Kafka retained partitioned stream. Key events by the domain ordering key; replay and independent consumers motivate this choice. rows remain in the source database; a relay publishes after commit. Buffer independent producers and consumers, with bounded and replay semantics.

Tradeoff: Missed notifications must reconcile

Connected operations: version ready; signal

Coordination / ownership

Regional Updaters

Download, validate, stage next version

Why, tradeoff and connected operations

Make ownership/version changes explicit; downstream resources must reject stale owners.

Tradeoff: Rollout skew across regions

Connected operations: download; signal; ref swap

Cache / in-memory index

Redis / In-memory Rule Matcher

v41 → v42 swap; lookup

Why, tradeoff and connected operations

An in-memory matcher makes request checks fast. Loading a validated generation and switching it atomically avoids mixing old and new rules. This derived serving structure avoids a lookup per request; it is not the rule-editing authority.

Tradeoff: Memory footprint; delayed version switch

Connected operations: ref swap; allow / reject; check

Gateway / routing

Edge / Gateway

Check IP and allow or block

Why, tradeoff and connected operations

Centralize admission and routing while keeping business-state ownership downstream.

Tradeoff: Adds per-request lookup latency

Connected operations: allow / reject; check; Pass validated input

Backend service

Incoming Requests

High-rate traffic checks

Why, tradeoff and connected operations

Isolate this operation so it can scale and fail independently from storage.

Tradeoff: Burst traffic pressures edge capacity

Connected operations: Pass validated input

Engineering control room

Deep dives — decisions, failures and recovery

Open a deep dive to follow the steps, try an example and see how recovery works.

Deep dive 1

Replace the rule set in one step

Build and verify the next rule set before switching the gateway to it.

Read the explanation and worked example
How it works

Build the next rule index away from the serving path. Verify schema, checksum, record count and required signatures before marking the generation ready. Each matcher switches one active-generation reference, so one request never reads half an old rulebook and half a new one.

Walk through an example

A download stops after 70 percent of the . Activating it would silently remove the rules that were never fetched.

Failure and recovery

Keep serving the last verified generation and alert on its age. Rollback changes the active pointer to another verified generation; it must not skip independent emergency safety rules.

Why this helps

Changing the live matcher piece by piece can let a request see only half of an update.

What you give up

Keeping the old and new versions briefly uses extra memory, but makes switching and rollback straightforward.

Deep dive 2

Catch gateways that missed an update

Use notifications for speed and periodic checks to repair missed announcements.

Read the explanation and worked example
How it works

An update event is a useful wake-up hint, but regions must periodically compare their installed generation with the authoritative . Download missing immutable artifacts and verify them before activation. Store installation progress so a restart does not imply success.

Walk through an example

A region misses the one notification announcing generation 105. Without polling it may remain on 104 forever even though the event system later recovers.

Failure and recovery

Use freshness-age alarms and periodic to repair missed hints. Protect the service from synchronized polls with and cached immutable downloads.

Why this helps

One lost notification should not leave a gateway using old rules forever.

What you give up

Polling adds background requests. Spread the checks over time and alert when a gateway's rules are older than the allowed limit.

Deep dive 3

Keep checking requests when publishing is down

Keep the last verified rules and decide how long they may be used.

Read the explanation and worked example
How it works

For each protected endpoint, define how old a verified rule set may be and what happens after that limit. A security-sensitive check may reject requests; another product may accept with explicit risk. Make that decision part of policy rather than an accidental timeout default.

Walk through an example

The service is unreachable for two hours. The edge can still perform fast lookups, but its rule freshness may no longer meet the security promise.

Failure and recovery

Expose installed version and age in metrics. Recovery activates a fully verified version; do not clear the failure mode merely because a network connection has reopened.

Why this helps

An unavailable source does not mean the correct rule set is empty.

What you give up

Old rules can block something that is now allowed or miss a new threat. Show rule age and define when to keep serving, reject checks or apply an approved override.

Deep dive 4

What happens if a region fails?

Let each region keep checking requests using a complete, verified rule set.

Read the explanation and worked example
How it works

One service publishes a complete rules file and a small record describing its version and contents. Each region downloads the file, checks that it is complete and valid, then replaces its current rule set in one step. Regions do not have to switch at the same instant; each reports the version it is using and how old it is.

Walk through an example

One region misses version 106 while another has already activated it.

Failure and recovery

Each region periodically checks for a newer version, so a lost update notification does not leave it behind forever. It keeps using its last verified rules until the replacement passes validation, within the allowed age limit. Only the current publisher may announce a new authoritative version.

Why this helps

Each gateway already has the full rule set in memory. It can keep checking requests even when the services that publish new rules are down. We can also see exactly which version each region is using.

What you give up

A new rule may take about a minute to reach every region. That delay lets gateways keep checking requests without waiting on a network call. Requiring every region to switch at once would add coordination and could stop checks during a network outage.

Tradeoffs and alternatives

DecisionTradeoff / alternative and recovery implication
Replace the rule set in one stepKeeping the old and new versions briefly uses extra memory, but makes switching and rollback straightforward.
Catch gateways that missed an updatePolling adds background requests. Spread the checks over time and alert when a gateway's rules are older than the allowed limit.
Keep checking requests when publishing is downOld rules can block something that is now allowed or miss a new threat. Show rule age and define when to keep serving, reject checks or apply an approved override.
What happens if a region fails?A new rule may take about a minute to reach every region. That delay lets gateways keep checking requests without waiting on a network call. Requiring every region to switch at once would add coordination and could stop checks during a network outage.

Production scars & failure modes

Failure investigation

A regional updater downloads a truncated snapshot.

Look for: Check checksum, record count, generation and freshness age.

Recovery and invariant: Retain the last verified edition, reject incomplete activation and alert on freshness. Define fail-open or fail-closed behavior when the last good edition becomes too old.

Component / failureImpactRecovery mechanismAlternative / tradeoff
Source format/signature invalidA new cannot be trusted.Quarantine the generation, retain last-known-good state and alert the owner.Availability continues with stale policy rather than silently deleting valid rules.
Object download corruptA region receives unusable compiled state.Verify checksum/schema before staging and retry an alternate replica.Never swap the active pointer before validation.
Bad rule blocks a large rangeA logically valid deployment can still cause an outage.Canary regions, compare match-rate deltas and roll back the generation with audit.Urgent policy changes still need proportional rollout safeguards.
Updater/controller unavailableMatchers continue with existing local data.Reconcile after recovery and alert on maximum allowed policy age.At that bound choose the documented risk-specific fail mode.

90-second interview summary

I would design the distributed blocking system by separating policy management from high-throughput request enforcement.

On the , fetcher services ingest government and security feeds, normalize and validate the rules, and store them in a canonical generation. A Builder compiles these into efficient prefix-based structures for , , and domain matching.

The system validates the and publishes it immutably to object storage, then announces a versioned . Regional updaters retrieve the new , verify its integrity, and atomically switch the local active matcher.

Every gateway evaluates requests using a complete in-memory , avoiding network dependencies in the critical request path.

Because we allow approximately one minute of propagation delay, regions can temporarily serve different validated versions. Notifications provide fast propagation, while periodic polling handles missed updates.

For resilience, I would retain old snapshots for rollback, validate unexpected rule-count changes, use to prevent stale publishers, and continue serving the last known good during control-plane outages.

The central tradeoff is accepting bounded rule staleness in exchange for low-latency, highly available enforcement.

Explain it without looking

Explain replace the rule set in one step

Reveal answer

Build and verify the next rule set before switching the gateway to it.

Changing the live matcher piece by piece can let a request see only half of an update.

Keeping the old and new versions briefly uses extra memory, but makes switching and rollback straightforward.

Explain catch gateways that missed an update

Reveal answer

Use notifications for speed and periodic checks to repair missed announcements.

One lost notification should not leave a gateway using old rules forever.

Polling adds background requests. Spread the checks over time and alert when a gateway's rules are older than the allowed limit.

Explain keep checking requests when publishing is down

Reveal answer

Keep the last verified rules and decide how long they may be used.

An unavailable source does not mean the correct rule set is empty.

Old rules can block something that is now allowed or miss a new threat. Show rule age and define when to keep serving, reject checks or apply an approved override.

Explain what happens if a region fails?

Reveal answer

Let each region keep checking requests using a complete, verified rule set.

Each gateway already has the full rule set in memory. It can keep checking requests even when the services that publish new rules are down. We can also see exactly which version each region is using.

A new rule may take about a minute to reach every region. That delay lets gateways keep checking requests without waiting on a network call. Requiring every region to switch at once would add coordination and could stop checks during a network outage.

Revision checklist

Revision checklist

  • Reconstruct replace the rule set in one step: Build and verify the next rule set before switching the gateway to it.
  • Reconstruct catch gateways that missed an update: Use notifications for speed and periodic checks to repair missed announcements.
  • Reconstruct keep checking requests when publishing is down: Keep the last verified rules and decide how long they may be used.
  • Reconstruct what happens if a region fails?: Let each region keep checking requests using a complete, verified rule set.
  • Name the authoritative state, boundary, retry identity and failure-domain durability guarantee.
  • Explain one alternative and exactly which guarantee you would relax.
  • Redraw the request and recovery paths without looking; mark what required a hint.

60-minute interview outline

60-minute interview walkthrough

TimeFocusWhat to cover
0–5 minIntroductionsIntroduce yourself briefly and confirm the interview format.
5–15 minScope and scaleDefine which IP or domain rules are in scope. Agree on acceptable propagation delay and stale-rule behavior.
15–30 minHigh-level designDraw the rule intake, canonical store, builder, object storage, regional updaters, and gateway matcher.
30–45 minDeep divesExplain validation and activation. Compare local matching with a remote lookup for each request.
45–55 minFailure and recoveryWalk through a missed update or malformed . Poll for the , keep the last valid version, and explain rollback.
55–60 minWrap-upSummarize the design and its main tradeoff. Leave time for questions.
On this page
  1. Problem statement
  2. Functional requirements
  3. Non-functional requirements
  4. Back-of-the-envelope estimates
  5. Entities
  6. API design
  7. High-level design
  8. High-level design component walkthrough
  9. Engineering control room
  10. Deep dives — decisions, failures and recovery
  11. Tradeoffs and alternatives
  12. Production scars & failure modes
  13. 90-second interview summary
  14. Explain it without looking
  15. Revision checklist
  16. 60-minute interview walkthrough

Save & sync your Atlas progress

Sync your profile and topic progress across browsers, then return to the same study desk.

Google sign-in will appear here after its Azure provider is configured.

Architecture diagram