Skip to main content
[ PIER ]

Redis

The in-memory data store that powers half the internet.

DatabaseCluster-ready#cache#nosql#key-value

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. 1Open the Pier dashboard and click Add service.
  2. 2Pick Redis from the template list.
  3. 3Choose the version, set a service name, and Pier provisions the container, storage, and ports automatically.
  4. 4Attach 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

Basic cache patternbash
# SET with TTL — 60-second cache
redis-cli SET user:42:profile '{"name":"Aleksandr"}' EX 60

# GET
redis-cli GET user:42:profile
Atomic counter (page views, rate limit)bash
# 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
Sorted-set leaderboardbash
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
Stream with consumer groupbash
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 MemcachedMemcached 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 ValkeyValkey 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 KeyDBMultithreaded Redis fork. Pier doesn't ship a KeyDB template by default — use a custom Docker template if you need it.
vs RabbitMQ for queuesRabbitMQ 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?
As of March 2024, Redis moved to the source-available SSPL/RSALv2 dual license. The official `redis` Docker image still works and Pier deploys it. If you want strict OSS, use the Valkey template — it's a BSD fork maintained by the Linux Foundation and is API-compatible.
Will I lose data if the container restarts?
By default Redis persists via RDB snapshots (every few minutes) + AOF (append-only file). Pier mounts /data as a persistent volume so restarts preserve state. For mission-critical durability, configure `appendfsync always`.
How much memory should I allocate?
Sum your hot dataset + 25% headroom. Set `maxmemory` and `maxmemory-policy allkeys-lru` to evict old keys before OOM. Pier's resource limits in the service settings control container memory.
Can I run Redis as a cluster?
Not yet via this template — Redis Cluster requires special multi-port setup. For now the template runs single-node. Use the Valkey template if you want similar functionality with an OSS license.
How do I connect from my application?
Use the connection string Pier shows on the service page — typically `redis://:password@host:6379`. Every major language has a client (jedis, ioredis, redis-py, redis-rs, lettuce).
Default password?
Pier generates a strong random password (REDIS_PASSWORD env var) on creation. Visible in the service detail page; rotate via the change-password action.
Pub/Sub vs Streams — which one?
Pub/Sub is fire-and-forget (no persistence, no consumer groups). Streams persist messages and support consumer groups with replay and acks — closer to Kafka semantics. Use Streams for anything where missing a message is a problem.

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 →