Preparing your design workspace

Loading the problem and your latest saved attempt…

Design Protection for a Public Website

Put a protection layer in front of a public website that absorbs floods, blocks known attacks, slows bots and credential stuffing, and lets a security team change its rules without blocking real users.

Problem statement

Design how to protect a public website from attacks and abuse.

For this exercise, assume one company runs a popular public website: web pages, a JSON API that its own pages and mobile app call, and a login endpoint. The website's own servers (the origin) run in one region. You design the protection layer between the internet and the origin.

All public traffic enters through the company's edge: about 20 locations around the world, each with its own servers, where users' connections end. The edge checks every request before passing it on, and the origin accepts traffic only from the edge.

For this exercise, assume the protection layer must handle four kinds of threat: - floods (DDoS, distributed denial of service: many machines sending traffic at once to knock the site over), both raw network floods and floods of valid-looking web requests; - requests carrying known attack patterns such as SQL injection (input crafted to run commands on the website's database), which a WAF (web application firewall: a set of rules that inspects each request) can block; - bots (automated clients) that scrape pages or abuse the API; - credential stuffing (scripts that try username and password pairs leaked from other sites) and password guessing on the login endpoint.

For this exercise, assume a small security team owns the rules and limits. They need to change them quickly, try a new rule without blocking anyone, and see what was blocked and why.

Out of scope: fixing bugs in the website's own code, internal security such as employee access and secrets, payment fraud, content moderation, and how a bot-detection model is trained.

What to build

  1. Every request first reaches a nearby edge location and is allowed, blocked, challenged (asked to prove it comes from a real browser or person) or slowed down by the current rules and limits before it reaches the origin; the origin cannot be reached any other way.
  2. During a flood, real users can keep using the site, and the origin never receives more requests than it can serve.
  3. The login endpoint stops credential stuffing and password guessing without locking real users out of their accounts.
  4. The security team can add, try in log-only mode (record what would be blocked, block nothing), turn on and roll back rules and limits, switch a stricter attack mode on or off, and see recent decisions with the reason for each.

At scale

  • For this exercise, assume a normal peak of 50,000 requests a second across all edge locations, including 500 login attempts a second of which about 10% fail; the origin can serve at most 80,000 requests a second.
  • For this exercise, assume floods of up to 1 Tbps of network traffic and up to 2 million web requests a second from about 500,000 IP addresses (about 4 requests a second each), and credential stuffing of up to 20,000 login attempts a second from more than a million IP addresses, each trying about one login a minute. Together the edge locations can take 2 Tbps and inspect 4 million requests a second, but attack traffic does not spread evenly across them.
  • For this exercise, assume the checks add at most 10 ms at p99 (for 99% of requests) to a normal request, and a rule change or a new block reaches every edge location within 60 seconds.
  • For this exercise, assume every block and challenge decision and 1% of allowed requests are logged, visible to the team within 1 minute and kept for 30 days.