Skip to main content

The Problem

During free trial periods, bots can rapidly create accounts to abuse your service. You need to limit the total number of signups across your entire application without blocking legitimate users.

Solution: Global Fixed Window Rate Limit

Use a global rate limit with a fixed window strategy to cap total signups per hour. This doesn’t require user authentication since it applies to all signups collectively.

Configuration

convex/rateLimits.ts
Why fixed window? Tokens are granted all at once at the start of each hour, making the limit predictable. The random start time prevents all retries from happening at the exact same moment.

Implementation

Backend Mutation

convex/auth.ts

Client-Side Usage

src/SignupForm.tsx

Testing the Rate Limit

Verify the limit is working:
convex/test.ts
Run in your Convex dashboard:

Common Variations

Best Practice: Monitor your signup rate limit metrics. If legitimate users are frequently hitting the limit, increase the rate or use a per-IP rate limit instead.
Global rate limits affect all users. Consider combining with:
  • Per-IP rate limits for finer control
  • CAPTCHA after multiple failed attempts
  • Email verification before activation