Today I am proud to announce Laravel Horizon, which provides a beautiful dashboard and code-driven configuration system for the Laravel Redis queue.
In addition to the new code-driven configuration system, Horizon also has a beautiful dashboard UI, It is completely open source and free for the entire Laravel community. We will release a test version tomorrow , I hope You will love it.
Translator's Note: As of October 2019, Horizon has released version 3.4.1
Dashboard
The Horizon Dashboard is a beautiful single-page Vue application that can be installed directly into an existing application via a simple composer require laravel/horizon
. It provides real-time insights into queued workloads, recent jobs, failed jobs, job retries, throughput and runtime metrics, and process counts. Control dashboard authentication through a simple callback registered with Horizon::auth
, giving you full control over access to your dashboard.
Configuration
Horizon is a great new way to configure Laravel queues. Similar to Laravel's scheduler, all queue workers are configurable through code:
Having this configuration in your code means it's all under source control, making it easy for your team to to collaborate. In the config/horizon.php
file, we configure the number of processes to create, the queues to be processed, the queue timeout, and any other settings that need to be passed to the queue:work
Artisan command .
Then, to start all queue workers, just a simple command: php artisan horizon
. No other command line options are required. This command reads the Horizon configuration and configures all required worker processes.
After you install and deploy Horizon to a production environment, you can modify the entire queue worker configuration by modifying the configuration file and redeploying.
Failed Tasks
Horizon provides a clear and detailed interface for inspecting and retrying failed tasks (yes, we all have them). You can view the exception stack trace, label, and recent retry record for the task. It would be nice to have failed task details displayed directly on the page. Since the retry is linked to the original task that failed, you no longer need to blindly try to enter queue:retry
at the console and determine whether its retry completed successfully or failed again:
Tag Monitoring
Horizon allows you to assign tags to tasks, including Email
, Broadcasts
, Notifications
, and Queued Listeners
. In fact, Horizon intelligently tags most tasks based on the Eloquent Model attached to the queue.
You can easily search for queue tasks through these tags to view specific customer tasks or other queue tasks in the program. This feature allows you to quickly focus on high-value customers, or find failed tasks for customers who just submitted a support ticket:
balancing
Horizon can automatically balance based on the workload of the queue Queue worker process in queue. For example, if the default
queue is empty but the notifications
queue is filled with queue tasks, Horizon can automatically assign tasks from notifications
to default
Queue to help process these tasks quickly.
After the queues catch up, Horizon will ensure that tasks are redistributed fairly across all queues.
Metric Charts
Horizon provides throughput and average runtime charts, allowing you to view throughput and runtime trends for individual tasks or for an entire fleet. These metric snapshots are captured using the horizon:snapshot
command, which can be set to run every minute using Laravel's built-in task scheduler. This allows you to quickly spot performance degradation after deployment.
Notifications
When one of your queues reaches a certain load, Horizon will send both Slack and SMS notifications. You can easily configure wait time thresholds to determine when notifications are sent. This means you always know when the queue needs more processes. Once notified, Horizon's code-driven configuration allows you to quickly make configuration changes to add more processes.
Conclusion & Thanks
I would like to give special thanks to Mohamed Said, David Hemphill, and Steve Schoger, who all contributed to the design and development of Horizon. Steve designed the user interface, David Hemphill implemented the interface as a Vue application, and Mohamed connected the front end to the Horizon backend I implemented.