๐— ๐˜† ๐Ÿฐ,๐Ÿฎ๐Ÿฌ๐Ÿฌ ๐——๐—ผ๐—น๐—น๐—ฎ๐—ฟ ๐—”๐—ฃ๐—œ ๐— ๐—ถ๐˜€๐˜๐—ฎ๐—ธ๐—ฒ

I thought my API was safe. I installed rate limiting. My tests passed.

Then someone scraped 2 million requests in 4 hours. It cost me 4,200 dollars.

Here is why it failed.

I ran 4 server instances. Each instance had its own memory. This meant the limit was 4 times higher than I thought.

The attacker used 2,000 proxy IPs. This bypassed my IP limits.

The result:

I rebuilt the system with three layers:

  1. Distributed limits I used Redis. Now all servers share one limit. 100 requests means 100 requests total.

  2. Pattern detection IPs are useless against proxy pools. I now track:

  1. Cost circuit breakers I assigned a dollar cost to every endpoint. I set a limit of 50 dollars per hour. If costs spike, the system throttles expensive endpoints.

Lessons learned:

Security theater is dangerous. It gives you false confidence.

How do you handle rate limiting?

Source: https://dev.to/kollittle/i-thought-my-api-was-rate-limited-until-someone-scraped-2-million-requests-in-4-hours-509d

Optional learning community: https://t.me/GyaanSetuAi