You need Redis for caching, rate limiting, or session storage. Traditional Redis requires a server, persistent connection, and doesn't work in serverless environments where connections are ephemeral.
What if Redis worked over HTTP — no persistent connections, no server management, pay-per-request pricing?
That's Upstash. Serverless Redis and Kafka designed for edge computing and serverless functions.
Free Tier
- 10,000 commands/day
- 256 MB storage
- Global replication available
Usage
import { Redis } from "@upstash/redis";
const redis = new Redis({
url: process.env.UPSTASH_REDIS_URL,
token: process.env.UPSTASH_REDIS_TOKEN,
});
// Basic operations
await redis.set("user:123", { name: "Aleksej", role: "admin" });
const user = await redis.get("user:123");
// With expiration (caching)
await redis.set("cache:products", products, { ex: 3600 }); // 1 hour TTL
// Lists, sets, sorted sets — all Redis commands work
await redis.lpush("queue:tasks", "task-1", "task-2");
await redis.sadd("online:users", "user:123");
await redis.zadd("leaderboard", { score: 100, member: "player1" });
Rate Limiting (Built-in)
import { Ratelimit } from "@upstash/ratelimit";
import { Redis } from "@upstash/redis";
const ratelimit = new Ratelimit({
redis: Redis.fromEnv(),
limiter: Ratelimit.slidingWindow(10, "10 s"), // 10 requests per 10 seconds
});
// In your API handler
const { success, limit, remaining } = await ratelimit.limit(userId);
if (!success) return new Response("Rate limited", { status: 429 });
Works Everywhere
// Cloudflare Workers — just works (HTTP-based)
// Vercel Edge Functions — just works
// AWS Lambda — just works
// Deno Deploy — just works
// Any serverless environment — just works
No connection pooling, no TCP setup, no REDIS_URL with port and password.
Choose Upstash for serverless/edge Redis. Choose traditional Redis for high-throughput dedicated servers.
Start here: upstash.com
Need custom data extraction, scraping, or automation? I build tools that collect and process data at scale — 78 actors on Apify Store and 265+ open-source repos. Email me: Spinov001@gmail.com | My Apify Actors
Top comments (0)