Skip to main content

Overview

Upstash Redis uses an HTTP/REST-based connection model instead of traditional TCP connections. This fundamental difference makes it ideal for serverless and edge environments.

HTTP-based architecture

Unlike traditional Redis clients that maintain persistent TCP connections, the Upstash Redis SDK communicates with Redis over HTTP:

Why HTTP instead of TCP?

The connectionless HTTP model provides several advantages for modern applications:

No connection management

You don’t need to worry about connection pooling, timeouts, or reconnection logic:

Perfect for serverless

Serverless functions have short lifecycles and unpredictable scaling. HTTP connections work seamlessly:
Benefits for serverless:
  • No cold start overhead: No connection establishment delay
  • No lingering connections: No idle connections consuming resources
  • Infinite scaling: Each invocation is independent
  • No connection limits: Not constrained by connection pool size

Edge runtime compatible

Many edge runtimes (Cloudflare Workers, Vercel Edge, Deno Deploy) don’t support TCP connections. HTTP works everywhere:

Globally distributed

HTTP requests can be routed through CDNs and edge networks for lower latency:

How it works

Each Redis command becomes an HTTP POST request:

Single command

Translates to:

Response format

HTTP response:
By default, responses are base64-encoded to safely handle non-UTF8 data. The SDK automatically decodes them. See client configuration to customize this.

Batch operations with pipelining

To reduce latency when executing multiple commands, use pipelining to send them in a single HTTP request:
See pipeline and auto-pipeline for details.

Performance considerations

Latency

HTTP adds some overhead compared to raw TCP, but this is minimal:
  • Single commands: ~1-2ms additional latency
  • Pipelined commands: Overhead amortized across all commands
  • Global read regions: Can reduce latency significantly for reads

Optimization strategies

Use pipelining for multiple commands:
Enable auto-pipelining:
Use keep-alive for connection reuse:

Comparison with TCP Redis clients

Authentication

HTTP connections use Bearer token authentication:
Never expose your token in client-side code. The token provides full access to your database.

Request timeout and cancellation

Use AbortSignal to cancel long-running requests:

Error handling

HTTP errors are transparently handled:
The SDK automatically retries on transient failures. See client configuration for retry options.