Overview
Redis is an in-memory data structure store used as a database, cache, and message broker. Convox supports both containerized Redis and AWS ElastiCache-managed instances.Basic Configuration
Define a Redis resource inconvox.yml:
Containerized Redis
For development and staging environments, use containerized Redis:Custom Images
Use custom Redis images:The
image field allows you to use any compatible Redis image. Always include an image tag.AWS ElastiCache Redis
For production workloads, use AWS ElastiCache for enhanced durability, high availability, and managed operations:Configuration Options
The compute and memory capacity of the cache node. Common values:
cache.t3.micro- 0.5 GiB memorycache.t3.small- 1.37 GiB memorycache.t3.medium- 3.09 GiB memorycache.m5.large- 6.38 GiB memorycache.r5.large- 13.07 GiB memory (memory-optimized)
Redis engine version (e.g., 6.2, 7.0, 7.1)
Prevent accidental deletion of the cache cluster. This is a Convox-managed feature that prevents resource removal even if deleted from
convox.yml.Create a Multi-AZ deployment with automatic failover for high availability
Enable encryption at rest for data stored on disk
Enable in-transit encryption (TLS) for data flowing between your application and Redis
Automatically apply minor engine version patches during maintenance windows
ElastiCache replication group ID to import an existing cluster
Advanced Features
Import Existing ElastiCache
Import an existing AWS ElastiCache Redis cluster:The replication group ID of the existing ElastiCache Redis cluster
While
import is set, the cache cluster is read-only from Convox’s perspective. Remove import to allow Convox to manage the cluster configuration.High Availability Configuration
For production workloads, enable Multi-AZ with automatic failover:Encryption Configuration
Enable both at-rest and in-transit encryption:When
transitEncryption is enabled, your Redis connection URL will use rediss:// (Redis with TLS) instead of redis://.Environment Variables
When linked to a service, Redis resources inject these environment variables:CLI Operations
List Resources
Get Resource Information
Proxy to Redis
Create a local tunnel to the Redis instance:The
proxy command is particularly useful for ElastiCache instances that are not publicly accessible.Connection Examples
- Node.js
- Python
- Ruby
- Go
Production Best Practices
Enable Deletion Protection
Set
deletionProtection: true to prevent accidental deletion of production cache clusters.Use Multi-AZ
Enable
durable: true for automatic failover and high availability in production.Enable Encryption
Use both
encrypted: true and transitEncryption: true for comprehensive data protection.Right-Size Your Instances
Monitor memory usage and choose appropriate cache node types (use r5 family for memory-intensive workloads).
Common Use Cases
Session Storage
Store user sessions with automatic expiration and fast access times.
Application Cache
Cache database queries, API responses, and computed results to reduce latency.
Rate Limiting
Implement rate limiting using Redis counters with expiration.
Job Queues
Use Redis as a message broker for background job processing (with libraries like Sidekiq, Bull, etc.).
Example Configurations
- Development
- Staging
- Production