Traditional Redis costs $15/month minimum even when idle. Upstash Redis is serverless — you pay per command. 10K commands/day free.
What is Upstash?
Upstash provides serverless Redis, Kafka, QStash (message queue), and Vector — all with per-request pricing. Perfect for serverless apps where you can't maintain persistent connections.
Why Upstash for Serverless
1. HTTP-Based Redis (No TCP Connections)
import { Redis } from '@upstash/redis';
const redis = new Redis({
url: process.env.UPSTASH_REDIS_REST_URL,
token: process.env.UPSTASH_REDIS_REST_TOKEN,
});
// Works in Vercel Edge, Cloudflare Workers, Deno Deploy
await redis.set('user:1', { name: 'Alice', role: 'admin' });
const user = await redis.get('user:1');
HTTP-based — no connection pooling needed. Works in every serverless runtime.
2. Rate Limiting (One Line)
import { Ratelimit } from '@upstash/ratelimit';
import { Redis } from '@upstash/redis';
const ratelimit = new Ratelimit({
redis: Redis.fromEnv(),
limiter: Ratelimit.slidingWindow(10, '10 s'),
});
// In your API handler
const { success, remaining } = await ratelimit.limit(userId);
if (!success) return new Response('Too many requests', { status: 429 });
3. QStash (Serverless Message Queue)
import { Client } from '@upstash/qstash';
const qstash = new Client({ token: process.env.QSTASH_TOKEN });
// Send message to your endpoint (with retries)
await qstash.publishJSON({
url: 'https://myapp.com/api/process',
body: { orderId: '123', action: 'fulfill' },
retries: 3,
delay: '10s',
});
// Schedule recurring tasks
await qstash.schedules.create({
destination: 'https://myapp.com/api/cleanup',
cron: '0 * * * *', // Hourly
});
4. Vector Database
import { Index } from '@upstash/vector';
const index = new Index({
url: process.env.UPSTASH_VECTOR_REST_URL,
token: process.env.UPSTASH_VECTOR_REST_TOKEN,
});
// Store embeddings
await index.upsert([
{ id: 'doc1', vector: embedding1, metadata: { title: 'React Guide' } },
{ id: 'doc2', vector: embedding2, metadata: { title: 'Vue Tutorial' } },
]);
// Semantic search
const results = await index.query({
vector: queryEmbedding,
topK: 5,
includeMetadata: true,
});
5. Serverless Kafka
import { Kafka } from '@upstash/kafka';
const kafka = new Kafka({
url: process.env.UPSTASH_KAFKA_REST_URL,
username: process.env.UPSTASH_KAFKA_REST_USERNAME,
password: process.env.UPSTASH_KAFKA_REST_PASSWORD,
});
const producer = kafka.producer();
await producer.produce('orders', JSON.stringify({ orderId: '123' }));
const consumer = kafka.consumer();
const messages = await consumer.consume({ consumerGroupId: 'group1', topic: 'orders' });
Free Tier
| Service | Free |
|---|---|
| Redis | 10K commands/day |
| QStash | 500 messages/day |
| Vector | 10K queries/day |
| Kafka | 10K messages/day |
Upstash vs Traditional Redis/Kafka
| Upstash | Self-hosted Redis | AWS ElastiCache | |
|---|---|---|---|
| Connection | HTTP (stateless) | TCP (persistent) | TCP (VPC only) |
| Pricing | Per request | Per hour | Per hour |
| Cold cost | $0 | $15+/month | $12+/month |
| Edge compatible | Yes | No | No |
| Setup | 30 seconds | Manual | 5+ minutes |
Getting Started
npm install @upstash/redis @upstash/ratelimit @upstash/qstash
Sign up at upstash.com → create database → copy REST URL and token.
The Bottom Line
Upstash makes Redis, Kafka, and vector search serverless-native. HTTP-based, per-request pricing, and compatible with every edge runtime. If you're building on Vercel or Cloudflare, Upstash is the missing piece.
Need data tools? I build scraping solutions. Check my Apify actors or email spinov001@gmail.com.
Top comments (0)