Skip to content

perf(api): bucket rate limit counters#857

Draft
ugcodrr wants to merge 2 commits into
mainfrom
perf/api-rate-limit-buckets
Draft

perf(api): bucket rate limit counters#857
ugcodrr wants to merge 2 commits into
mainfrom
perf/api-rate-limit-buckets

Conversation

@ugcodrr
Copy link
Copy Markdown
Member

@ugcodrr ugcodrr commented May 30, 2026

Summary

  • replace per-request sorted-set rate limit entries with per-second Redis hash buckets
  • run the weighted limit check, bucket cleanup, request increment, and TTL update atomically through Lua
  • use a ratelimit:v2:* key prefix so existing sorted-set keys expire without type conflicts
  • add API Vitest coverage for recent-request bucket totals and reset timing

Verification

  • pnpm --filter api test:types
  • pnpm --filter api lint
  • pnpm test apps/api/src/auth/auth.service.test.ts --run

@github-actions github-actions Bot added the api label May 30, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented May 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
statsify Skipped Skipped Jun 1, 2026 9:14am

@ugcodrr ugcodrr marked this pull request as draft May 30, 2026 11:25
* add RateLimitException class to handle rate limit errors
* update AuthGuard to set response headers on rate limit exceeded
* modify auth service to throw RateLimitException when limit is exceeded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant