Introducing laravel horizon

Time:2020-1-14

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

Dashboard

Introducing laravel horizon
The horizon dashboard is a beautiful single page Vue application that can be accessed through a simplecomposer 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. adoptHorizon :: authRegistered simple callbacks control the authentication of the dashboard, so that you have full control over access to the dashboard.

To configure

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. stayconfig/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 toqueue: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.

Failed tasks

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 consolequeue:retryAnd determine whether its retry completed successfully or failed again:

Label monitoring

Horizon allows you to assign tags to tasks, including EmailBroadcastsNotificationsandQueued 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:

balance


Horizon can automatically balance the queue processes in the queue according to the workload of the queue. For example, ifdefaultThe queue is empty, butnotificationsIf the queue is full of queue tasks, horizon can automaticallynotificationsTasks assigned todefaultQueues to help with these tasks quickly.

When the queue catches up, horizon ensures that tasks are reallocated fairly across all queues.

Index chart


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 thehorizon: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.

notice


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.

Recommended Today

ASP.NET Example of core MVC getting the parameters of the request

preface An HTTP request is a standard IO operation. The request is I, which is the input; the responsive o is the output. Any web development framework is actually doing these two things Accept the request and parse to get the parameters Render according to the parameters and output the response content So let’s learn […]