Skip to content

Design an API Rate Limiter, stage 8 of 10: change it

Credential stuffing on login

Login is unauthenticated, so there is no API key. The traffic is not one heavy client; it is thousands of light ones.

System so far· 5 parts
1234CLIENTAPI clientsEDGELoad balancerSERVICEAPI instancesCACHERedisDATABASEPostgres

Select a component to see what it is responsible for and which state it owns.

  1. 1API clients → Load balancer: Requests with API key
  2. 2Load balancer → API instances: Round-robin across instances
  3. 3API instances → Redis: Atomic take-tokens script
  4. 4API instances → Postgres: Admitted requests; plan lookups (cached)

What you need to know

0 of 2 checks done
  1. Credential stuffing tests leaked email–password pairs from other sites against your login page. Attackers spread the attempts over thousands of IPs, often residential proxies, so each IP makes only a few attempts an hour.

    A rate limit catches abuse that is concentrated in the key it counts by. Distributed attacks are built to stay under every per-key limit.

  2. Work it out

    8,000 IPs each try 4 passwords an hour. About how many login attempts is that per day?
    attempts per day