KatInterview

Blocking Government-Listed IPs at the Edge of a Global Service

System DesignModel answer
MediumModel answerSystem Designsystem-designnetworkingcaching

Last updated

Design a fleet-wide system that rejects connections from IP addresses a regulator flags as prohibited, using only the regulator's per-address lookup API as the source of truth.

A national regulator requires your online service to turn away traffic from any IP address on its prohibited list. The regulator exposes an API: you submit an IP address, and it replies whether that address is prohibited. You cannot modify this API, and it remains the authoritative record.

Design the system that enforces this rule across your entire fleet of servers.

Treat this as a conversation. Interviewers in this style of round usually look at two things beyond the architecture itself:

  • Whether you verify your assumptions before building on them (IP versions, available infrastructure, API behavior) instead of silently inventing numbers.
  • Whether you lead the discussion, starting with a simple design and refining it in steps, each step motivated by a concrete weakness.

You are given very little up front. Traffic volume, API limits, fleet size, and the required freshness of ban data are all things you must ask about or state as labeled assumptions.

Part 1: Scope and a baseline. Settle the scope and requirements, then present the simplest compliant design and explain where it fails.

Part 2: Enforcement at scale. Rework the design so each connection is checked quickly at your edge without calling the regulator on every attempt. Explain where the check runs, what data structure stores the bans, and how ban data reaches every enforcement point.

Part 3: Freshness, failure, and evidence. Describe how newly added and removed bans propagate within the freshness target, what happens to connections that are already open when an address becomes banned, how the system behaves when the regulator's API or your own sync pipeline is down, and how you can prove compliance afterward.

Questions worth raising early: Is IPv6 in scope? Does the API support only single lookups, or also bulk export or change feeds? What are its rate limits, latency, and availability? Are bans single addresses or CIDR ranges? How quickly must changes take effect? Which traffic and protocols are covered? If the API is down and an address is unknown, should you block or allow? Will you need records of refused connections?

Hints

Hint 1

Start by listing what you must ask: IP versions, single addresses versus CIDR ranges, whether the API offers bulk or delta export, rate limits, and the freshness target. Label every number you then use as asked or assumed.

Hint 2

A per-connection call to the regulator couples your latency and availability to theirs and will hit rate limits. Move the decision to a local, in-memory structure on each edge node that supports longest-prefix matching for both IPv4 and IPv6, and fill it asynchronously.

Hint 3

Treat fail-open versus fail-closed as an explicit policy to be approved by the owner of the compliance obligation, and don't forget three things: connections already established, an audit trail of refusals, and alerting on data staleness.