Skip to content
Pro Analyzer — Available with ShieldCI Pro

Redis Status Analyzer

Analyzer IDCategorySeverityTime To Fix
redis-status✅ ReliabilityCritical15 minutes

What This Checks

This analyzer verifies Redis connectivity, health, and configuration across all configured connections. It performs a comprehensive series of checks on each Redis connection:

  • PING test - Sends a PING command and expects a PONG response to verify basic connectivity and authentication
  • Read/write verification - Writes a test key with a 60-second TTL, reads it back, and verifies the value matches, then cleans up
  • Memory usage - Retrieves Redis INFO and checks memory usage against maxmemory; warns at 80% usage, critical at 95%
  • Connected clients - Monitors connected client count against maxclients; warns at 80% capacity
  • Persistence configuration - For connections used by queues or sessions, verifies that AOF or RDB persistence is enabled
  • All connections - Tests every configured Redis connection (from database.redis), not just the default

Why It Matters

Redis is a critical infrastructure component for many Laravel applications. When Redis fails or degrades:

  • Cache failures - Application performance degrades dramatically as every request hits the database
  • Queue processing halts - Queued jobs (emails, payments, notifications) stop being processed entirely
  • Session loss - Users are logged out and lose in-progress work if sessions are stored in Redis
  • Broadcasting failures - Real-time features (websockets, notifications) stop working
  • Memory exhaustion - Redis running out of memory can cause key eviction, leading to cache stampedes and data loss
  • Connection exhaustion - Running out of client connections blocks all new application requests
  • Data loss on restart - Without persistence (AOF/RDB), queue jobs and session data are lost on Redis restart

How to Fix

Quick Fix (5 minutes)

  1. Verify Redis is running and accessible:
bash
# Check if Redis server is running
redis-cli ping
# Expected: PONG

# Check Redis status
sudo systemctl status redis

# Start Redis if not running
sudo systemctl start redis
  1. Update .env with correct connection details:
ini
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
  1. Test the connection from Laravel:
bash
php artisan tinker
>>> Illuminate\Support\Facades\Redis::connection()->ping()

Proper Fix (15 minutes)

  1. Configure Redis connections properly in config/database.php:
php
// config/database.php
'redis' => [
    'client' => env('REDIS_CLIENT', 'phpredis'),

    'default' => [
        'host' => env('REDIS_HOST', '127.0.0.1'),
        'password' => env('REDIS_PASSWORD'),
        'port' => env('REDIS_PORT', '6379'),
        'database' => env('REDIS_DB', '0'),
    ],

    'cache' => [
        'host' => env('REDIS_HOST', '127.0.0.1'),
        'password' => env('REDIS_PASSWORD'),
        'port' => env('REDIS_PORT', '6379'),
        'database' => env('REDIS_CACHE_DB', '1'),
    ],

    'queue' => [
        'host' => env('REDIS_HOST', '127.0.0.1'),
        'password' => env('REDIS_PASSWORD'),
        'port' => env('REDIS_PORT', '6379'),
        'database' => env('REDIS_QUEUE_DB', '2'),
    ],
],
  1. Enable persistence for queue and session connections:
bash
# redis.conf - Enable AOF (recommended for queues/sessions)
appendonly yes
appendfsync everysec

# Enable RDB snapshots as backup
save 900 1
save 300 10
save 60 10000

On managed Redis, persistence is controlled by the provider, not redis.conf — enable AOF/RDB (or confirm the tier is durable) from the provider's dashboard.

  1. Configure memory limits:

On self-hosted Redis, the fastest way to set a maxmemory limit and eviction policy is via redis-cli (takes effect without a restart):

bash
redis-cli CONFIG SET maxmemory 256mb
redis-cli CONFIG SET maxmemory-policy allkeys-lru

To persist across restarts, add the same settings to redis.conf. ShieldCI will show the exact config file path in the issue location when it can be detected from Redis. In Docker/containers, pass these as flags to the Redis entrypoint:

yaml
# docker-compose.yml
services:
  redis:
    image: redis:alpine
    command: redis-server --maxmemory 256mb --maxmemory-policy allkeys-lru

On managed Redis (Laravel Cloud, ElastiCache, Upstash), set the memory limit and eviction policy from the provider's dashboard instead.

  1. Monitor connection limits:
bash
# redis.conf - increase if needed
maxclients 10000
  1. Handle high memory situations:
php
// Clear cache if memory is high
php artisan cache:clear

// Or selectively clear tags
Cache::tags(['reports'])->flush();

ShieldCI Configuration

This analyzer is automatically skipped in CI environments ($runInCI = false).

Why skip in CI?

  • Redis is typically unavailable in CI pipelines, which are stateless and ephemeral
  • CI environments often use an array or null driver for in-memory testing, not a real Redis instance
  • Redis connectivity is an infrastructure concern, not a code-correctness concern that CI should gate on

When to run this analyzer:

  • Local development: Ensures Redis is accessible during development
  • Staging/Production servers: Confirms Redis health and configuration
  • After infrastructure changes: Run after Redis upgrades, migrations, or configuration changes
  • CI/CD pipelines: Skipped automatically (Redis may not be available)

Specify which Redis connections to check:

By default, the analyzer automatically tests all connections defined in database.redis — including any under database.redis.clusters — while excluding the framework-reserved keys (client, options, clusters, cluster). If you want to configure the connections to check, publish the config:

bash
php artisan vendor:publish --tag=shieldci-config

Then in config/shieldci.php:

php
'analyzers' => [
    'reliability' => [
        'enabled' => true,

        'redis-status' => [
            'connections' => ['default', 'cache', 'queue'],
        ],
    ],
],

Suppress the persistence check on provider-managed connections:

On managed Redis (Laravel Cloud, ElastiCache, Upstash) durability is handled by the provider. Once you've confirmed that, list the connections to skip the "no persistence configured" finding for them:

php
// config/shieldci.php
'analyzers' => [
    'reliability' => [
        'enabled' => true,

        'redis-status' => [
            'managed_durable_connections' => ['default', 'sessions'],
        ],
    ],
],

References