- Every webhook runs exactly once
- Verify the signature, claim the event ID in Redis with SET NX, then act. A retry finds the claim and stops.
- Money-moving actions take a lock
- Refunds, cancellations and payouts take a short Redis lock with a random token, released by compare-and-delete, so one request can never free another's lock.
- The server decides the price
- Checkout recomputes every price on the server. A delayed job and a daily cron reconcile any order whose payment confirmation never arrived.
- Slow work leaves the request path
- Delayed tasks go to a queue. A message that fails three times moves to a dead-letter queue. Scheduled jobs run from a scheduler, not a timer that dies on deploy.
- Limits and caches degrade gracefully
- Rate limits use an atomic sliding window and fall back to memory if Redis is down. A cache outage slows reads but never breaks them.
- Secrets and access tiers
- Inputs are validated, secrets are encrypted and kept out of git, and every procedure is public, signed-in, employee or admin.
- Ship small, roll back fast
- One deploy at a time, a one-command rollback to any earlier commit, and alerts on errors and failed jobs.