Kritim Yantra
Apr 30, 2025
In modern web applications, queues play a crucial role in improving performance, scalability, and user experience. Whether it's sending emails, processing image uploads, or executing time-consuming tasks, Laravel queues help offload heavy jobs from the main request-response cycle.
But how do you monitor, manage, and optimize those background jobs?
Meet Laravel Horizon – a beautifully designed dashboard and powerful queue manager built specifically for Laravel's Redis-based queue system.
In this blog, we'll explore what Laravel Horizon is, why it's a game-changer, how to set it up, and best practices for using it in production.
Laravel Horizon is an elegant queue monitoring dashboard for Laravel applications that use the Redis queue driver. Developed by the Laravel team, it provides:
Horizon is tailored exclusively for Redis, making it ultra-fast and efficient.
Here’s why Laravel Horizon is a must-have for serious Laravel developers:
Feature | Benefit |
---|---|
✅ Real-time Monitoring | See job status updates live as they happen |
📊 Metrics & Analytics | View average job runtime, throughput, and job trends |
💥 Failed Job Management | Easily retry or inspect failed jobs |
⚙️ Queue Load Balancing | Auto-adjust worker queues for optimal performance |
🚦 Tag-Based Filtering | Track specific job types using custom tags |
📁 Redis Integration | Seamless performance on Laravel’s Redis queue |
Installing Horizon is as easy as running a few Artisan commands:
composer require laravel/horizon
php artisan horizon:install
This will publish the config/horizon.php
file, where you can configure workers, supervisors, and environments.
php artisan horizon
Visit http://your-app.test/horizon
and enjoy your new dashboard!
Laravel Horizon works by managing supervisors — processes that monitor your queue workers. In config/horizon.php
, you define the number of workers, queues, balance strategy, and connection.
'environments' => [
'production' => [
'supervisor-1' => [
'connection' => 'redis',
'queue' => ['default'],
'balance' => 'auto',
'processes' => 10,
'tries' => 3,
],
],
],
Horizon uses Redis not just to store queued jobs, but also for metrics, tags, and recent job tracking.
Here’s what the Horizon dashboard offers:
Gives you an overview of queue metrics like job runtime, queue wait time, and throughput.
Lists recent jobs with their statuses (pending, completed, failed). You can view detailed info, tags, and retry jobs directly from the UI.
View the error stack trace and retry failed jobs with a single click.
See graphs of queue performance over time—perfect for debugging performance issues or traffic spikes.
View each worker's real-time activity, restart them, and monitor queue health.
Horizon runs as a long-lived process. In production, you should daemonize it using a process manager like Supervisor or systemd.
[program:horizon]
process_name=%(program_name)s
command=php /path-to-your-app/artisan horizon
autostart=true
autorestart=true
user=www-data
redirect_stderr=true
stdout_logfile=/path-to-your-app/storage/logs/horizon.log
Restart Supervisor:
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start horizon
By default, Horizon is accessible to anyone who visits /horizon
. In production, you should restrict access.
Update the HorizonServiceProvider
:
Horizon::auth(function ($request) {
return auth()->check() && auth()->user()->isAdmin();
});
You can also use Laravel Sanctum or custom middleware for more control.
You can tag jobs using the tags()
method in your job class:
public function tags()
{
return ['order:'.$this->orderId];
}
This allows you to track jobs related to specific users, orders, or events directly in Horizon.
Feature | php artisan queue:work |
Laravel Horizon |
---|---|---|
Monitoring UI | ❌ | ✅ Real-time dashboard |
Metrics | ❌ | ✅ Job runtime, wait time, graphs |
Auto-Scaling | ❌ Manual configuration | ✅ Balance and scaling options |
Retry Jobs UI | ❌ | ✅ Click-to-retry failed jobs |
Tags & Filtering | ❌ | ✅ Tags, filters, tracking |
If your project has growing queue demands, Horizon is a no-brainer upgrade.
Laravel Horizon is more than just a pretty interface—it's a powerful tool for building, maintaining, and scaling queue-driven applications. With live metrics, a polished UI, and Redis-powered performance, Horizon gives developers the tools they need to confidently manage background processing in production.
Whether you’re running a SaaS platform, e-commerce store, or real-time notification system, Horizon gives you full visibility and control over your job queues.
🧠 Code with confidence. Monitor with elegance. That’s the power of Laravel Horizon.
No comments yet. Be the first to comment!
Please log in to post a comment:
Sign in with Google