What This Is
Redis is an in-memory data store that operates at a fundamentally different speed tier than disk-based databases. Where a MySQL query might take 5-50 milliseconds to read from disk, parse the query, and return results, Redis returns cached data in under a millisecond. That speed difference is what makes the gap between a web application that feels sluggish and one that feels instant.
We run Redis in production across our own platforms as a multi-purpose data layer. It serves as the cache backend for our Laravel applications — storing computed values, API responses, and rendered fragments that would otherwise require expensive database queries or external API calls on every request. It powers our queue system, holding job payloads for background workers that process email sending, webhook handling, AI tool execution, and other async operations. It manages session storage for authenticated users. And it provides the pub/sub mechanism that Laravel Broadcasting uses for real-time event delivery.
Redis is not a replacement for MySQL or PostgreSQL. It is a complement. Relational databases store your authoritative data with ACID guarantees, durability, and complex query capabilities. Redis stores the ephemeral, frequently-accessed, or time-sensitive data that sits between your application logic and your database — the cache layer, the job queue, the session store, the rate limiter. Using Redis for what it does best means your relational database handles only the queries that actually need it.
When You Need This
Redis is the right choice when your application needs fast data access for caching, queuing, or real-time features beyond what your primary database delivers efficiently. Common scenarios:
- Your application has expensive database queries that produce the same results for many requests and should be cached
- You need a queue backend for background job processing — email sending, webhook handling, report generation, or any async work
- Session storage needs to be faster than database-backed sessions and shared across multiple application servers
- Your application requires rate limiting that tracks request counts per user or IP with automatic expiry
- Real-time features need a pub/sub system for broadcasting events to connected clients
- Leaderboards, counters, or ranked lists need atomic increment operations and sorted set data structures
- Application response times are bottlenecked by repeated database queries that could be served from cache
This is not needed for simple applications with light traffic where database query times are acceptable and background processing is minimal. Redis adds operational complexity — a service to monitor, memory to provision, and persistence to configure.
How We Work
Redis integration follows Laravel’s built-in abstractions wherever possible. Laravel provides drivers for cache, session, queue, and broadcasting that use Redis as the backend. Application code interacts with these abstractions — Cache::get(), dispatch(), session() — without coupling to Redis-specific APIs. If the backend changes (unlikely, but possible), the application code does not.
Cache strategy is deliberate, not blanket. We cache specific things for specific durations based on how expensive they are to compute and how stale they can be. An API response from an external service that changes daily gets a 1-hour TTL. A complex dashboard aggregation query gets a 5-minute TTL. User session data gets the session lifetime. We do not cache everything and hope for the best — that approach leads to stale data bugs that are harder to diagnose than the performance problems the cache was meant to solve.
Queue configuration is tuned for the application’s job mix. High-priority jobs (user-initiated actions that need fast feedback) run on separate queues from low-priority jobs (batch reports, cleanup tasks). Queue workers are supervised by systemd with automatic restart on failure. Failed jobs are logged and retried with exponential backoff. Permanently failed jobs are stored for inspection and manual retry.
Memory management is planned from the start. Redis stores everything in RAM, so the total dataset size is constrained by available memory. We configure maxmemory policies that evict least-recently-used cache entries when memory pressure increases, ensuring queues and sessions are never evicted in favour of cache data. Memory usage is monitored with alerts at threshold levels.
What You Get
- Application caching — targeted caching of expensive queries, API responses, and computed values with appropriate TTLs
- Queue backend — reliable background job processing with priority queues, retry logic, and failure handling
- Session storage — fast, shared session management across application servers
- Rate limiting — per-user and per-IP request throttling with automatic expiry
- Real-time broadcasting — pub/sub backend for Laravel Broadcasting and WebSocket event delivery
- Data structures — sorted sets, hash maps, lists, and sets for application-specific use cases
- Memory monitoring — usage tracking, eviction policy configuration, and capacity planning
Technologies We Use
- Redis 7 — current version with Redis Functions, ACL improvements, and multi-part AOF persistence
- Laravel Cache — cache driver with tags, atomic locks, and flexible TTL management
- Laravel Queue — job dispatching with Redis-backed queues, retries, and rate limiting
- Laravel Broadcasting — real-time event broadcasting with Redis pub/sub
- Predis / phpredis — PHP Redis client libraries for Laravel integration
- Redis Sentinel — high-availability configuration with automatic failover
- Redis CLI — command-line inspection and debugging of keys, memory, and performance
Related Systems
Redis works alongside MySQL and PostgreSQL as the caching and queuing layer in Laravel applications. Queue jobs power background processing for business automation and AI development. Real-time broadcasting enables live updates in React frontends via Pusher. Redis runs on Linux servers alongside the application stack.
Talk to Us About Redis
If your application needs caching, background job processing, or real-time features powered by Redis, get in touch and we will assess where Redis fits your architecture.