One Redis, five jobs: how Upstash keeps my job board's AI costs and serverless state in check A developer behind PMHNP Hiring, a niche job board for psychiatric nurse practitioners, detailed how a single Upstash Redis database handles five jobs across the site's Vercel-hosted Next.js app, including rate limiting, AI response caching and serverless shared state. The AI gateway checks the cache before spending rate-limit budget, so repeat requests return instantly without consuming a slot or triggering a paid model call. The developer also described keying rate limits by route and IP, with shared budgets for crawlers that rotate addresses. Sponsored by Upstash https://upstash.com/?utm source=sathish-daggula . I picked the topic, the code is from my production app, and the opinions are mine. I was running Upstash Redis on this site before they reached out. Upstash found me through my earlier post on rate limiting Next.js routes for scrapers. This is the sequel: everything else Redis ended up doing. PMHNP Hiring runs on Vercel, so no two requests are guaranteed to share memory. One Upstash Redis database is the shared memory the app doesn't otherwise have. It does five jobs: Below is the real code for each, what broke along the way, and what I'd change. PMHNP Hiring https://pmhnphiring.com is a niche job board for psychiatric nurse practitioners. It's Next.js on Vercel, Postgres on Supabase through Prisma, and a handful of AI features: resume review, cover letters, candidate scoring for employers, and a re-ranker for talent search. I wrote earlier about rate limiting Next.js API routes for scrapers https://dev.to/sathish daggula/how-to-rate-limit-nextjs-api-routes-for-scrapers-1p34 . That covered IP limits. This post is everything else Redis ended up doing once it was in the stack. Every module creates its client the same way, and every one of them works without Redis: js import { Redis } from '@upstash/redis'; const redis = process.env.UPSTASH REDIS REST URL && process.env.UPSTASH REDIS REST TOKEN ? new Redis { url: process.env.UPSTASH REDIS REST URL, token: process.env.UPSTASH REDIS REST TOKEN, } : null; Why Upstash and not a Redis box: it speaks HTTP, so it works from serverless and edge functions with no connection pool to babysit, and it bills per request, which fits a site whose traffic comes in waves. Versions in this post: @upstash/redis 1.41 and @upstash/ratelimit 2.2. Every limit in the app lives in one table. There are 24 of them, from "3 job posts a minute" to "10 candidate messages a day": js export const RATE LIMITS = { postJob: { limit: 3, windowSeconds: 60 }, auth: { limit: 10, windowSeconds: 60 }, publicDetail: { limit: 240, windowSeconds: 60 }, candidateMessage: { limit: 10, windowSeconds: 86400 }, dataRequest: { limit: 3, windowSeconds: 3600 }, // ...19 more } as const; The check itself is a thin wrapper around @upstash/ratelimit https://upstash.com/docs/redis/sdks/ratelimit-ts/gettingstarted?utm source=sathish-daggula with a sliding window: js const limiter = new Ratelimit { redis, limiter: Ratelimit.slidingWindow config.limit, ${config.windowSeconds} s , analytics: true, prefix: '@upstash/ratelimit', } ; const { success, reset, remaining } = await limiter.limit key ; The interesting part turned out to be the key, not the algorithm. Three shapes cover everything: ratelimit: