Upstash is the serverless data platform for Redis, Kafka, and QStash. Pay per request, scale to zero, use from edge functions — no server management.
What Is Upstash?
Upstash provides serverless Redis, Kafka, and a message queue (QStash) — all accessible via HTTP REST API, perfect for edge deployments.
Serverless Redis
import { Redis } from '@upstash/redis'
const redis = new Redis({
url: process.env.UPSTASH_REDIS_REST_URL!,
token: process.env.UPSTASH_REDIS_REST_TOKEN!,
})
// Basic operations
await redis.set('user:123', { name: 'Alice', plan: 'pro' })
const user = await redis.get('user:123')
// Rate limiting
import { Ratelimit } from '@upstash/ratelimit'
const ratelimit = new Ratelimit({
redis,
limiter: Ratelimit.slidingWindow(10, '10 s'), // 10 requests per 10 seconds
})
const { success, limit, remaining } = await ratelimit.limit('user:123')
if (!success) return new Response('Too many requests', { status: 429 })
REST API
export UPSTASH_URL="https://your-endpoint.upstash.io"
export UPSTASH_TOKEN="your-token"
# SET
curl -s "$UPSTASH_URL/set/mykey/myvalue" \
-H "Authorization: Bearer $UPSTASH_TOKEN"
# GET
curl -s "$UPSTASH_URL/get/mykey" \
-H "Authorization: Bearer $UPSTASH_TOKEN" | jq '.result'
# Pipeline (multiple commands in one request)
curl -s -X POST "$UPSTASH_URL/pipeline" \
-H "Authorization: Bearer $UPSTASH_TOKEN" \
-d '[["SET","counter","0"],["INCR","counter"],["INCR","counter"],["GET","counter"]]'
QStash (Message Queue)
import { Client } from '@upstash/qstash'
const qstash = new Client({ token: process.env.QSTASH_TOKEN! })
// Send message to be processed
await qstash.publishJSON({
url: 'https://my-app.com/api/process',
body: { orderId: 'order-123', action: 'fulfill' },
retries: 3,
})
// Schedule message
await qstash.publishJSON({
url: 'https://my-app.com/api/report',
body: { type: 'daily' },
cron: '0 9 * * *', // 9 AM daily
})
// Delayed message
await qstash.publishJSON({
url: 'https://my-app.com/api/reminder',
body: { userId: 'user-123', message: 'Your trial ends tomorrow' },
delay: 86400, // 24 hours
})
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!,
})
// Produce
const producer = kafka.producer()
await producer.produce('events', JSON.stringify({ type: 'click', page: '/pricing' }))
// Consume
const consumer = kafka.consumer()
const messages = await consumer.consume({ consumerGroupId: 'my-group', topic: 'events', autoCommit: true })
messages.forEach(m => console.log(JSON.parse(m.value)))
Free Tier
| Service | Free Tier |
|---|---|
| Redis | 10K commands/day, 256MB |
| QStash | 500 messages/day |
| Kafka | 10K messages/day |
Need a cache for scraped data? Scrapfly + Upstash Redis = fast cached scraping. Email spinov001@gmail.com for optimized data pipelines.
Top comments (0)