๐—ฅ๐—ฎ๐˜๐—ฒ-๐—Ÿ๐—ถ๐—บ๐—ถ๐˜๐—ฒ๐—ฑ ๐—ช๐—ฒ๐—ฏ๐—ต๐—ผ๐—ผ๐—ธ๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐—ฃ๐—›๐—ฃ ๐—ฎ๐—ป๐—ฑ ๐—ฆ๐—ค๐—Ÿ๐—ถ๐˜๐—ฒ

A viral video crashed our system. We hit 14,000 webhook deliveries in one minute. Partner sites went down. The queue grew to 92,000 rows.

We fixed this with a boring stack. We use PHP 8.4 and SQLite in WAL mode. Cloudflare Workers handle the edge.

Here is the design:

We put token buckets in SQLite. We avoid Redis to keep it simple.

We use short leases for workers. This stops two workers from sending the same event. If a worker dies, the lease expires. Another worker picks it up.

We protect privacy for GDPR. We strip usernames from payloads. We use hashed tokens.

Boring choices keep systems honest. Flashy tools break at 3am.

Source: https://dev.to/ahmet_gedik778845/rate-limited-webhook-delivery-for-video-events-with-php-84-and-sqlite-wal-4hj2