Laravel Horizon is a dashboard and queue monitoring tool specifically designed for Laravel applications that use Redis queues. It provides a clean, real-time interface to monitor, configure, and manage your queued jobs. Essentially, it makes working with Laravel queues much more transparent and manageable. Here’s a detailed breakdown:
1. Purpose of Laravel Horizon
Horizon is built to help developers:
- Monitor queue jobs: See which jobs are pending, processing, failed, or completed.
- Track metrics: Job throughput, runtime, failures, and retries.
- Manage queues: Configure workers, set priorities, and control how jobs are processed.
- Receive alerts: Notifications for failed jobs or performance issues.
2. Features
- Dashboard: Provides a web UI showing all your queues, job stats, and failures.
- Job Monitoring: Tracks each job’s status, duration, and retries.
- Queue Configuration: Lets you define multiple queues with different priorities and worker counts.
- Failed Job Management: Easily retry failed jobs from the dashboard.
- Metrics & Statistics: Provides graphs and historical data for job throughput and runtime.
- Notifications: Can send Slack or other alerts on job failures.
3. How It Works
Horizon runs as a separate process that listens to your Redis queues and provides statistics to the dashboard. It uses Redis as the backend to track jobs and metrics efficiently.
4. Installation
You can install Horizon using Composer:
composer require laravel/horizon
Then publish its assets and configuration:
php artisan horizon:install
php artisan migrate
Start Horizon to process jobs and monitor them:
php artisan horizon
The dashboard is usually accessible at:
http://your-app.test/horizon
5. Use Cases
- Large applications with many background jobs like email sending, notifications, image processing.
- Applications where queue monitoring and metrics are critical.
- Teams needing a visual interface for queue management.
In short, Laravel Horizon makes queue management transparent, measurable, and controllable, making it ideal for production-ready Laravel apps using Redis.
What is Laravel Horizon?
How is Horizon different from Laravel’s default queue worker?
queue:work only processes jobs, while Horizon provides:Dashboard (UI monitoring)
Auto balancing of workers
Detailed job metrics & failure tracking
Easy scaling with supervisors
Which queues are supported by Horizon?
How do you install Laravel Horizon?
composer require laravel/horizon php artisan horizon:install php artisan migrateWhat is the role of horizon:install and horizon:publish?
horizon:install → Publishes Horizon’s migrations.horizon:publish → Publishes Horizon’s assets/config files.Where is Horizon’s configuration stored?
config/horizon.php.How do you define supervisors in Horizon?
config/horizon.php under supervisors key. Example:'supervisors' => [ 'default' => [ 'connection' => 'redis', 'queue' => ['default'], 'balance' => 'auto', 'processes' => 3, 'tries' => 3, ], ],What are balancing strategies in Horizon?
simple → Distributes jobs evenly across workers.auto → Dynamically balances workers based on queue load.false → No balancing, fixed queue assignment.What is the use of horizon:supervisor command?
config/horizon.php.How do you scale Horizon workers?
processes value in supervisor config OR use Linux Supervisor/systemd to run multiple Horizon processes.How do you access the Horizon dashboard?
/horizon.Can Horizon dashboard be restricted to certain users?
App\Providers\HorizonServiceProvider → use Horizon::auth(function ($user) { return $user->isAdmin(); });What metrics can Horizon monitor?
How does Horizon handle failed jobs?
failed_jobs table (via DB) and also shown in Horizon dashboard with details.How do you retry failed jobs from Horizon dashboard?
Difference between queue:work and horizon?
queue:work → Basic job processing.horizon → Advanced monitoring, auto balancing, retry & dashboard.What is the purpose of horizon:terminate?
How do you deploy Horizon in a load-balanced environment?
How does Horizon handle job prioritization among queues?
queue array in supervisor config decides priority. Example:'queue' => ['high', 'medium', 'low']What is the difference between Supervisor in Horizon and Linux Supervisor?
config/horizon.php to manage workers.Linux Supervisor → A system process manager that keeps
php artisan horizon running.How does Horizon automatically balance workers across queues?
balance => 'auto', Horizon dynamically assigns workers to queues based on job load.