← Questions

Design a bot detection system

0
GoogleAmazonAI/ML design

An AI/ML design interview question asked at Google and Amazon. It tests anomaly detection, classification and adversarial ml.

Design a system that separates automated traffic from real users on a large website, in real time. Bots scrape content, stuff credentials, create fake accounts and inflate clicks; some are harmless (search crawlers). Whatever you deploy, the bad bots adapt to it, so the system must keep learning.

Requirements

  • Functional: score each request or session as human or bot; decide an action per score (allow, rate-limit, challenge with a CAPTCHA, block); let known good bots through; give analysts a way to label traffic and review decisions.
  • Non-functional: decisions add only a few milliseconds to each request at very high request rates; very few real users are challenged; the system adapts within hours to new bot behavior.

Clarifying questions

  • Which bots matter most: scrapers, credential stuffing, fake signups, ad fraud?
  • Do we score each request, each session, or each account?
  • What signals are available: headers, IP and network data, client-side JavaScript signals, mouse and touch behavior, account history?
  • What is the cost of challenging a real user compared with letting a bot through?
  • Where do labels come from: CAPTCHA outcomes, confirmed abuse, manual review?

What a strong answer covers

  • Problem framing: binary classification at session level with request-level fast rules in front, and the action thresholds chosen from the relative costs.
  • Features: request rate and timing regularity, header and TLS fingerprints, IP reputation and data-center ranges, navigation patterns, client signals such as JavaScript execution and input events, and aggregates per IP, device and account over sliding windows.
  • Labels: CAPTCHA results, known-bad lists, honeypot hits, confirmed fraud, and the bias these introduce (you only learn about traffic you challenged); a small random holdout to measure what you miss.
  • Models: rules and a gradient-boosted model online, with heavier sequence or graph models offline to find coordinated bot networks.
  • Serving: an edge or gateway check with features from a low-latency store, a fallback when the scorer is slow, and challenges as a middle tier.
  • The adversarial loop: monitor score distributions and challenge-solve rates, retrain often, rotate detection signals, and keep some signals secret.

Follow-ups

  • Bots now solve CAPTCHAs with human farms. What do you change?
  • How do you measure recall when you never see the bots you missed?
  • A large company's office shares one IP address with thousands of users. How do you avoid blocking them?

Where it's asked

What it tests

anomaly detection · classification · adversarial ml

Your canvas
Draw your answer hereBoxes, arrows and notes, saved for you to come back to.Sign in to start drawing