Redis
Redis is an in-memory data structure store that functions as a database, cache, and message broker.
Classification
- ComplexityMedium
- Impact areaTechnical
- Decision typeTechnical
- Organizational maturityIntermediate
Technical context
Principles & goals
Use cases & scenarios
Compromises
- Data loss due to misconfiguration.
- Performance bottlenecks with insufficient memory.
- Security risks with improper use.
- Use appropriate data structures for your use cases.
- Configure persistence options to avoid data loss.
- Regularly monitor performance and memory usage.
I/O & resources
- Data to be stored in Redis.
- Configuration settings for Redis.
- Access requests from users.
- Data retrieved from Redis.
- Status information about the Redis instance.
- Error messages in case of issues.
Description
Redis is an open-source in-memory data structure store that stores data in key-value pairs. It supports various data structures such as strings, hashes, lists, sets, and more. Redis is commonly used for applications requiring high performance and low latency.
✔Benefits
- High performance and low latency.
- Easy scaling through sharding.
- Support for various data structures.
✖Limitations
- Limited storage compared to disk-based databases.
- Data loss on failure if persistence is not configured.
- Complexity in managing distributed instances.
Trade-offs
Metrics
- Response Time
The time taken to respond to a request.
- Throughput
The number of requests processed per unit of time.
- Memory Usage
The proportion of available memory used by Redis.
Examples & implementations
Caching Frequently Accessed Data
An application uses Redis to cache frequently accessed data such as user profiles to improve response times.
Using as a Pub/Sub System
Redis is used to publish and subscribe messages between different services in a microservices architecture.
Real-time Analytics
An application uses Redis to perform real-time data analytics by storing and processing data streams.
Implementation steps
Install and configure Redis.
Define the data structures to be used.
Implement the application logic to interact with Redis.
⚠️ Technical debt & bottlenecks
Technical debt
- Insufficient documentation of Redis usage.
- Lack of tests for Redis integration.
- Outdated configuration settings.
Known bottlenecks
Misuse examples
- Storing large binary files in Redis.
- Ignoring TTL (Time to Live) for cache data.
- Using Redis without a backup strategy.
Typical traps
- Assuming Redis is a complete database solution.
- Believing that all data in Redis is safe.
- Overlooking the need for monitoring tools.
Required skills
Architectural drivers
Constraints
- • Must be deployed in an environment with sufficient memory.
- • Requires an appropriate persistence strategy.
- • Must be securely configured to avoid security risks.