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:- 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
Response format
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: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:Comparison with TCP Redis clients
Authentication
HTTP connections use Bearer token authentication:Request timeout and cancellation
UseAbortSignal to cancel long-running requests: