SyntaxStudy
Sign Up
Laravel Queue Workers, Redis, and Horizon
Laravel Beginner 1 min read

Queue Workers, Redis, and Horizon

The Redis queue driver is the most popular choice for production Laravel applications due to its speed and reliability. It requires the predis/predis or phpredis PHP extension. In config/queue.php, set the default driver to redis and configure the connection. Jobs are stored as serialized JSON in Redis lists, and workers use blocking pops (BLPOP) to efficiently wait for new jobs without polling. Laravel Horizon is a beautiful dashboard and configuration system for Redis queues. It provides real-time monitoring of queue throughput, job failure rates, and worker counts. Horizon is configured in config/horizon.php, where you define supervisor pools with workers tailored to specific queues. Each pool can specify the queue connection, the number of workers, memory limits, and the balance strategy (auto, simple, or false). Horizon also offers tagged jobs for filtering, failed job management with easy retrying, metrics per job type, and notifications when a queue waits too long. It is started with php artisan horizon and must also be supervised by Supervisor in production. The horizon:pause and horizon:continue commands control Horizon without stopping the process, enabling zero-downtime deploys.
Example
# config/queue.php — use Redis driver
# 'default' => env('QUEUE_CONNECTION', 'redis'),

# Install Horizon
# composer require laravel/horizon
# php artisan horizon:install
# php artisan migrate

# config/horizon.php (simplified)
# 'environments' => [
#     'production' => [
#         'supervisor-1' => [
#             'connection' => 'redis',
#             'queue'      => ['high', 'default', 'low'],
#             'balance'    => 'auto',
#             'processes'  => 10,
#             'tries'      => 3,
#             'memory'     => 128,
#         ],
#     ],
# ],

# Start Horizon (foreground)
php artisan horizon

# Pause / continue without killing process
php artisan horizon:pause
php artisan horizon:continue

# List failed jobs
php artisan queue:failed

# Retry a specific failed job
php artisan queue:retry <job-id>

# Retry all failed jobs
php artisan queue:retry all

# Flush all failed jobs
php artisan queue:flush

# Process jobs from a specific queue
php artisan queue:work redis --queue=high,default --tries=3 --sleep=3