Deploying Upstash Redis
Serverless Redis with REST API, pay-per-request, and global regions.
PlatformsBeginner
Why
Upstash is serverless Redis with REST API (works in edge/Vercel), pay-per-request pricing, and multi-region. No connection limits — perfect for serverless.
Platform-as-a-Service adoption grew 24% in 2024 as teams shift from VM management to git-push deploys. the cloud infrastructure market reached $330B in 2024, growing 22% year-over-year (Synergy Research), and PaaS layers capture the majority of new workloads.
When
Use Upstash for serverless/edge apps needing Redis (rate limit, cache, queue). Avoid for high-throughput persistent connections.
How
1. Create — upstash.com → Create Redis Database
2. REST — get UPSTASH_REDIS_REST_URL + TOKEN
3. SDK — @upstash/redis for edge-friendly REST
4. Commands — redis.set/get/etc via REST
5. Multi-region — create in multiple regions, read nearest
6. QStash — message queue on top of Redis
7. Rate limit — @upstash/ratelimit for sliding window
Example
import { Redis } from "@upstash/redis";
const redis = new Redis({
url: process.env.UPSTASH_REDIS_REST_URL!,
token: process.env.UPSTASH_REDIS_REST_TOKEN!,
});
await redis.set("key", "value");
const value = await redis.get("key");
// Rate limiting
import { Ratelimit } from "@upstash/ratelimit";
const ratelimit = new Ratelimit({
redis,
limiter: Ratelimit.slidingWindow(10, "1 m"),
});
const { success } = await ratelimit.limit("user-id");
Common Problems
- ⚠REST slower than TCP — for hot paths, use TCP with ioredis
- ⚠Cost at high QPS — pay-per-request adds up, monitor usage
- ⚠Configuration drift between environments — use infrastructure-as-code (Terraform/Pulumi) to keep dev/staging/prod identical
Best Practices
- ✓Use REST for edge/serverless — works where TCP doesn't (Vercel, Workers)
- ✓Use @upstash/ratelimit for rate limiting — serverless, no state in your app
- ✓Set up health checks and graceful shutdown — handle SIGTERM to drain in-flight requests before exit