Quiz - Rate limiting with Upstash Redis
Your app is about to launch publicly on a custom domain with the Better Auth email-and-password sign-in form. You already have a Vercel WAF rule capping requests per IP on /api/auth/*. Is that enough?
Upstash is down for maintenance and limiter.limit(key) is throwing on every sign-in attempt. What’s the senior default for the auth path, and why?
rate_limit_unavailable error — because fail-closed would turn a limiter outage into a total sign-in outage for every user.A teammate declares new Ratelimit(...) inside the route handler’s POST function instead of at module scope. The counts in Redis still look correct in testing. What’s actually wrong?
ephemeralCache only survives if the limiter object survives between requests, which means module scope. Declared in the handler it’s rebuilt every call with an empty cache — the counts stay correct (so dev never reveals it), but every call hits Redis. The cost surfaces only under real traffic, as latency and bill.You’re rate-limiting an endpoint that calls an LLM: you want to tolerate a short burst of requests but cap sustained spend over time. Which algorithm fits, and why isn’t sliding window the obvious pick here?
The sign-in action runs two safeLimit calls on the same signInLimiter — one keyed ip:${ip}, one keyed email:${email}. Which statements about this design are correct? Select all that apply.
success values must be checked with their own early return; checking only the IP gate leaves the credential-stuffing vector wide open.ip: and email: prefixes on the key keep the two budgets in separate Redis counters even though they share one limiter and one prefix.if (!...) return and half the defense is silently off. The ip:/email: key prefixes split one limiter into two independent budgets (rl:signin:ip:... vs rl:signin:email:...). And the per-email budget must be comparable to or looser than per-IP: make it tighter and an attacker behind a shared NAT can burn a victim’s email budget and re-open the lockout vector.Sign-up is gated per-IP only, while sign-in and password reset are also gated per-email. Why does sign-up skip the per-email gate?
Quiz complete
Score by topic