The article was forwarded from the professional laravel developer community. Original link: https://learnku.com/laravel/t
Today, I am proud to announce laravel horizon, which provides a beautiful dashboard and code driven configuration system for laravel redis queues.
In addition to the new code driven configuration system, horizon also has a beautiful dashboard UIIt’s completely open source and free for the entire laravel community. We’ll release a beta tomorrow, I hope you will like it.
Translator’s note: as of October 2019, horizon has released version 3.4.1
The horizon dashboard is a beautiful single page Vue application that can be accessed through a simple
composer require laravel / horizonInstall directly into an existing application. It provides real-time insight into queue workload, recent jobs, failed jobs, job retries, throughput and runtime metrics, and process counts. adopt
Horizon :: authRegistered simple callbacks control the authentication of the dashboard, so that you have full control over access to the dashboard.
Horizon is a great new way to configure laravel queues. Similar to laravel’s scheduler, all queue workers can be configured by code:
Having this configuration in your code means that it’s all under source control, making it easy for your team to collaborate. stay
config/horizon.phpIn the file, we configure the number of processes to be created, the queues to be processed, the queue timeout, and the processes to be passed to
queue:workAny other settings for the artisan command.
Then, to start all the queue workers, you need a simple command:
php artisan horizon。 No other command line options are required. This command reads the horizon configuration and configures all necessary worker processes.
After installing and deploying horizon to the production environment, you can modify the configuration of the entire queue worker by modifying the configuration file and redeploying it.
Horizon provides a clear and detailed interface for checking and retrying failed tasks (yes, we do). You can view the exception stack trace, tag, and recent retry record for this task. It’s great to show the details of the failed tasks directly on the page. Since retrying is linked to the failed original task, you no longer need to blindly try to type in at the console
queue:retryAnd determine whether its retry completed successfully or failed again:
Horizon allows you to assign tags to tasks, including
Queued Listeners。 In fact, horizon intelligently labels most tasks based on the eloquest 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 enables you to quickly focus on high-value customers, or to find failed tasks for customers who have just submitted a support job:
Horizon can automatically balance the queue processes in the queue according to the workload of the queue. For example, if
defaultThe queue is empty, but
notificationsIf the queue is full of queue tasks, horizon can automatically
notificationsTasks assigned to
defaultQueues to help with these tasks quickly.
When the queue catches up, horizon ensures that tasks are reallocated fairly across all queues.
Horizon provides throughput and average uptime charts that allow you to view throughput and uptime trends for a single task or for an entire queue. These index snapshots use the
horizon:snapshotCommand, which can be set to run once per minute using laravel’s built-in task scheduling. This allows you to quickly detect performance degradation after deployment.
When one of your queues reaches a certain load, horizon sends both slack and SMS notifications. You can easily configure the wait time threshold to determine when notifications are sent. This means that you always know when the queue needs more processing. When notified, horizon’s code driven configuration allows you to quickly make configuration changes to add more processing.
Conclusion & thanks
I would like to thank Mohamed Said, David Hemphill and Steve Schoger in particular for their contributions to the design and development of Horizon. Steve designed the user interface, David Hemphill implemented it as a Vue application, and Mohamed connected the front end to the horizon back end I implemented.