Laravel Horizon and Redis Queue Management

Laravel Horizon is a powerful queue management tool provided by Laravel. It makes managing queue processing easy and efficient. When integrated with Redis, Laravel Horizon offers robust queue management and monitoring capabilities, enhancing the performance and reliability of your Laravel application.

Integrating Laravel Horizon with Redis

To integrate Laravel Horizon with Redis, you need to install Redis and Horizon, and then configure the options in the config/horizon.php file.

Step 1: Install Redis

First, install Redis on your server and ensure that Redis is running.

Step 2: Install Laravel Horizon

Install Laravel Horizon via Composer:

composer require laravel/horizon

Step 3: Configure Laravel Horizon

Open the config/horizon.php file and configure the Redis connection:

'redis' => [
    'driver' => 'redis',
    'connection' => 'default', // The Redis connection name configured in the config/database.php file
    'queue' => ['default'],
    'retry_after' => 90,
    'block_for' => null,
],

Step 4: Run Horizon Table

Run the following command to create the Horizon table in the database:

php artisan horizon:install

Step 5: Run Horizon Worker

Start the Horizon Worker using the command:

php artisan horizon

 

Using Laravel Horizon

After successful integration, you can manage queues and view queue status through the Horizon interface on /horizon.

Laravel Horizon provides various useful features, such as monitoring queue processing time, rescheduling tasks, managing failed jobs, and more advanced features.

 

Conclusion

Laravel Horizon is a powerful tool for managing queues in Laravel with Redis integration. It enhances performance and control over queue processing, ensuring your Laravel application operates efficiently and reliably.