Databases & Storage
Redis
An in-memory data store used for caching, sessions, rate limiting, queues and real-time pub/sub messaging.
What Redis is
Redis is an in-memory key-value data store that supports data structures such as strings, hashes, lists, sets, sorted sets and streams. It is commonly used as a cache and as a fast shared state layer between application instances, with optional persistence to disk.
What it solves
- Slow responses caused by repeated expensive database queries or API calls
- Sharing session and state data across multiple stateless application instances
- Rate limiting, counters and distributed locks
- Broadcasting real-time messages between server instances
When it makes sense
- Caching frequently read data and computed results
- Session storage and short-lived tokens
- Job queues for background processing in small to medium systems
- Pub/sub for scaling WebSocket servers horizontally
Strengths
- Very low latency for reads and writes
- Versatile data structures for many common patterns
- Simple to integrate and widely supported by libraries
- Available as a managed service from major cloud providers
Limitations
- Data size is limited by available memory, which affects cost
- Persistence options trade durability for performance; not a replacement for a primary database
- Cache invalidation logic adds complexity and potential for stale data
- Clustering and high availability require additional configuration
Alternatives, and when they are better
- PostgreSQL
For durable data, or for simple job queues in small systems, PostgreSQL avoids an extra component and provides transactional guarantees.
- Dedicated message brokers
RabbitMQ, Kafka or managed cloud queues are better when messages must be durable, ordered or replayed at high volume.
- Memcached
Memcached can be enough for pure, simple key-value caching where Redis data structures and persistence are not needed.
Practical examples
- Caching product catalog responses for an online store
- Rate limiting API requests per customer key
- Broadcasting chat messages across several WebSocket server instances
How it fits into the product architecture
Redis sits between the application layer and slower data sources as a cache and shared state store. It also often backs job queues and pub/sub channels. It should be treated as disposable or semi-durable: the system must tolerate cache loss, and memory usage, eviction and hit rates should be monitored.
Next step
Choosing a stack for a new product?
We start from requirements, costs of ownership and the team you will have, then recommend technology with the reasons written down.