SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 52
Design defensive detection and containment of coordinated bot traffic
A large consumer web service is being hit by automated traffic: credential stuffing on login, scraping of listing pages, and waves of fake signups. The traffic is spread across so many IP addresses and devices that each one looks harmless on its own, so simple per-IP rate limits stopped working. You are designing the defensive system that detects these coordinated campaigns and contains them while real users carry on normally.
Requirements
- Score each request to sensitive endpoints (login, signup, listing and search pages) for automation risk, using both signals from the request itself and aggregate behaviour across IPs, devices and accounts.
- Apply graduated responses: allow, add friction (a challenge or step-up verification), throttle, or block, per request and per detected campaign.
- Give analysts a view of detected campaigns, with the ability to tune, roll back and audit containment rules, and to review false-positive appeals.
- Continuously measure how often real users are wrongly challenged or blocked.
Constraints and assumptions
- 300,000 requests/s at peak overall, of which 20,000/s hit login and signup.
- Inline decisions may add at most 5 ms p99 at the edge. If the scoring service is unavailable, the edge must degrade gracefully rather than take the site down.
- Campaigns rotate across 100,000+ residential IP addresses, each sending 1-5 requests an hour, and change tactics within minutes of being blocked.
- Wrongly challenged or blocked logins must stay under 0.1% of legitimate sessions; a new campaign should be contained within 5 minutes of starting.
- Raw IP addresses and device signals may be retained for at most 30 days.
Out of scope for the first sketch
Network-layer volumetric DDoS mitigation · Building the internals of the machine learning models · Takedown or legal action against attack infrastructure · Account recovery for already-compromised users
Draw your design
Rough math and notes
SYSTEM DESIGN SKETCHBOOK / FOLLOW-UPS
Design defensive detection and containment of coordinated bot traffic
Finish your first sketch before answering these. Cross out freely.
- One IP sends 1,000 login attempts a minute. Where is that stopped, and why does the same rule miss the distributed version of the attack?
- 100,000 IPs each make two login attempts an hour against different accounts. What aggregate signals expose the campaign, and how do you compute them in time?
- A new rule blocks a mobile carrier gateway address shared by 20,000 real users. How would you have caught that before shipping it, or within minutes after?
- The scoring service is down. What does the edge do on login, on signup and on search pages?
- Attackers adapt within minutes of every block. How do you avoid teaching them exactly which signal gave them away?
Compare afterwards: worked approaches and reading at sketchbook /questions/botnet-defense/review