DEV Community

Alex Spinov
Alex Spinov

Posted on

Upstash Has a Free Redis API — Serverless Key-Value Store With 10K Commands/Day and Global Replication

Self-hosting Redis means managing memory, persistence, replication, and hoping your server does not run out of RAM at 3 AM.

Upstash gives you serverless Redis — pay per request, scale to zero, and connect from edge functions. The free tier includes 10,000 commands/day and 256MB storage.

What You Get for Free

  • 10,000 commands/day — reads and writes combined
  • 256 MB storage — enough for sessions, cache, rate limiting
  • REST API — HTTP-based, works from edge/serverless (no TCP needed)
  • Global replication — read replicas in multiple regions
  • Durable storage — data persists (not just in-memory)
  • TLS encryption — secure by default
  • QStash — free message queue (500 messages/day)

Quick Start

1. Create a Database

Sign up at upstash.com, create a Redis database, grab your REST URL and token.

2. Use the REST API (No SDK Needed)

# SET a key
curl "https://YOUR_ENDPOINT.upstash.io/set/user:1/alex" \
  -H "Authorization: Bearer YOUR_TOKEN"

# GET a key
curl "https://YOUR_ENDPOINT.upstash.io/get/user:1" \
  -H "Authorization: Bearer YOUR_TOKEN"
Enter fullscreen mode Exit fullscreen mode

3. Node.js SDK

npm install @upstash/redis
Enter fullscreen mode Exit fullscreen mode
import { Redis } from "@upstash/redis";

const redis = new Redis({
  url: "https://YOUR_ENDPOINT.upstash.io",
  token: "YOUR_TOKEN",
});

// Basic operations
await redis.set("session:abc", { userId: 1, role: "admin" }, { ex: 3600 });
const session = await redis.get("session:abc");

// Rate limiting
const key = `ratelimit:${userId}`;
const count = await redis.incr(key);
if (count === 1) await redis.expire(key, 60);
if (count > 100) throw new Error("Rate limited");

// Sorted set for leaderboard
await redis.zadd("leaderboard", { score: 1500, member: "player1" });
const top10 = await redis.zrange("leaderboard", 0, 9, { rev: true });
Enter fullscreen mode Exit fullscreen mode

4. Python

from upstash_redis import Redis

redis = Redis(url="https://YOUR_ENDPOINT.upstash.io", token="YOUR_TOKEN")

redis.set("key", "value", ex=3600)
value = redis.get("key")

# Hash
redis.hset("user:1", {"name": "Alex", "email": "alex@example.com"})
user = redis.hgetall("user:1")
Enter fullscreen mode Exit fullscreen mode

5. Works in Edge Functions

// Vercel Edge Function / Cloudflare Worker
export default async function handler(req) {
  const redis = new Redis({
    url: process.env.UPSTASH_REDIS_REST_URL,
    token: process.env.UPSTASH_REDIS_REST_TOKEN,
  });

  const visits = await redis.incr("page:visits");
  return new Response(`Visits: ${visits}`);
}
Enter fullscreen mode Exit fullscreen mode

No connection pooling, no TCP, no cold start issues. Pure HTTP.

Common Use Cases

Session storage: Store user sessions with TTL — no database queries on every request.

Rate limiting: Simple incr + expire pattern — protect your API in 5 lines of code.

Caching: Cache expensive database queries or API responses with automatic expiration.

Feature flags: Store flags in Redis, read in milliseconds, update without deployment.

Real-World Use Case

A developer running a Next.js app on Vercel told me: "I needed rate limiting for my API. Self-hosted Redis meant spinning up a server just for 10 keys. Upstash free tier handles it perfectly — 10K commands/day is way more than I need, and it works natively with edge functions."

Free Plan Limits

Feature Free Tier
Commands/day 10,000
Storage 256 MB
Databases 1
Global replicas No (paid)
QStash messages 500/day
Bandwidth 50 GB/month

The Bottom Line

If you need Redis but do not want to manage infrastructure — Upstash is Redis done right for the serverless era. HTTP API means it works everywhere, even where TCP connections are not allowed.


Need to cache scraped data or build a data pipeline? Check out my web scraping tools on Apify — extract data and pipe it wherever you need.

Building something custom? Email me at spinov001@gmail.com


More Free APIs You Should Know About

Top comments (0)