Redis
The in-memory data store that powers half the internet.
Redis is an in-memory key-value store with first-class support for strings, lists, sets, sorted sets, hashes, streams, and pub/sub. It's the default cache for web apps, the default message broker for background jobs, and the default session store for almost everything.
Deploy with Pier
- 1 Open the Pier dashboard and click Add service.
- 2 Pick Redis from the template list.
- 3 Choose the version, set a service name, and Pier provisions the container, storage, and ports automatically.
- 4 Attach a domain if you want HTTPS. Traefik auto-provisions the Let's Encrypt certificate.
What is Redis?
Redis (Remote Dictionary Server) is the de-facto in-memory database of the modern web. Sites at every scale use it: as a cache to take load off the primary database, as a session store, as a message queue broker, as a real-time counter, and as a pub/sub channel between services.
Its API is minimal — about 200 commands across a handful of data structures — but those primitives combine into surprisingly powerful patterns. INCR for counters and rate limiters. ZADD for leaderboards. LPUSH/RPOP for queues. Pub/Sub for fanout. Streams for Kafka-style logs. EXPIRE on every key for automatic cleanup.
How Pier deploys it
Pier uses the official redis Docker image with redis-server --requirepass
to enforce password authentication. The data volume mounts at /data, where
RDB snapshots and the AOF file persist. The default version is latest
(currently Redis 8 with RESP3 support); 7-alpine is also available for
strict 7.x compatibility.
Backups capture both the RDB and AOF files. Connection strings are auto-built
in the service page as redis://:password@host:6379 — paste straight into
your application config.
When NOT to use Redis
For long-term durable storage of business records — use PostgreSQL. For
content that must outlast a container restart with strict durability guarantees,
configure appendfsync always (slower) or move to Postgres. For multi-tenant
SaaS isolation, use Postgres’s row-level security — Redis databases (DB 0-15)
are not a security boundary.
Key features
Sub-millisecond latency
In-memory operations finish in microseconds. Persistence to disk (RDB snapshots + AOF) is asynchronous and configurable.
Rich data structures
Not just strings — lists, sets, sorted sets (ZSET), hashes, bitmaps, HyperLogLog, geospatial indexes, streams, and pub/sub channels.
Atomic operations
INCR, LPUSH, SADD, ZADD are atomic at the engine level. No client-side locking needed for counters, queues, leaderboards, rate-limiters.
Lua scripting & transactions
EVAL runs Lua scripts atomically — full multi-step logic without round-trips. MULTI/EXEC pipelines wrap several commands in one atomic block.
Pub/Sub & streams
Built-in pub/sub for fanout. Redis Streams give Kafka-style append-only logs with consumer groups, replay, and acks — without operating a Kafka cluster.
TTL on every key
Set per-key expiry with EXPIRE. Perfect for sessions, password reset tokens, idempotency keys, short-term caches.
Use cases
Application cache
Reduce database load by 90%+ by caching expensive queries, computed views, and rendered templates.
Session store
Move sessions out of cookies and out of Postgres into Redis. Sub-ms reads, automatic expiry, shared across multiple app servers.
Background job queue
Sidekiq (Ruby), Celery (Python), Bull (Node.js), Resque, RQ — most popular job queues use Redis as their broker.
Rate limiting
Token bucket / sliding window via INCR + EXPIRE. A few lines of code; survives any traffic spike.
Real-time leaderboards & counters
ZSET handles sorted leaderboards with millions of entries; ZINCRBY updates ranks in O(log N).
Code examples
# SET with TTL — 60-second cache
redis-cli SET user:42:profile '{"name":"Aleksandr"}' EX 60
# GET
redis-cli GET user:42:profile # Atomic increment; safe under heavy concurrency
redis-cli INCR views:home
# Sliding-window rate limit (60 requests per minute per IP)
redis-cli SET ratelimit:$IP 0 EX 60 NX
redis-cli INCR ratelimit:$IP redis-cli ZADD leaderboard 100 alice 95 bob 88 carol
# Top 3
redis-cli ZREVRANGE leaderboard 0 2 WITHSCORES
# Atomic rank bump
redis-cli ZINCRBY leaderboard 25 alice redis-cli XADD events '*' type signup user 42
redis-cli XGROUP CREATE events workers '$' MKSTREAM
redis-cli XREADGROUP GROUP workers w1 COUNT 10 STREAMS events '>' How it compares
| vs Memcached | Memcached is simpler but limited to strings and has no persistence, replication, pub/sub, or streams. Redis covers Memcached's use case plus everything else. |
| vs Valkey | Valkey is the open-source (BSD) fork of Redis after the license change in March 2024. API-compatible; pick Valkey if you want to stay on a fully OSS path. Pier ships both. |
| vs KeyDB | Multithreaded Redis fork. Pier doesn't ship a KeyDB template by default — use a custom Docker template if you need it. |
| vs RabbitMQ for queues | RabbitMQ wins on heavy AMQP routing semantics. Redis (with Streams or Bull/Sidekiq) wins on simplicity, latency, and operational footprint for the typical background-job use case. |
Frequently asked questions
Is Redis still open source?
Will I lose data if the container restarts?
How much memory should I allocate?
Can I run Redis as a cluster?
How do I connect from my application?
Default password?
Pub/Sub vs Streams — which one?
Related services
Deploy on your VPS
Redis is an in-memory key-value store with first-class support for strings, lists, sets, sorted sets, hashes, streams, and pub/sub. It's the default cache for web apps, the default message broker for background jobs, and the default session store for almost everything.
Deploy this service →