Laravel Horizon | Fonseka Innovations

Let’s have a look at Laravel Horizon and its key features.

To begin with, Horizon is a queue manager.

It will give you full control over the queues. That means you get to configure all the queues. Additionally, you can collect useful metric data and generate analytics on each queues performance.

Getting Started With Laravel Horizon

Like all libraries, Horizon will add a configuration file called horizon.php.

Firstly, you can start with this simple command,

php artisan horizon

If you take a look at the configuration file, you can setup supervisors for each environment. You can also add multiple supervisors to it. And each supervisor can be responsible for a particular set of workers.

Correspondingly by default, the supervisor will be monitoring the default queue.

Furthermore, there are few things you can change in a supervisor, there are;

  • Minimum and maximum number of workers allowed to run,
  • Timeout and delays for jobs,
  • Memory limits,
  • Sleep time,
  • Attempt counts,
  • Balancing strategies.

Also, you can check the below video to kick start your application with Horizon.

What is a Supervisor?

Laravel suggests using a process monitor for the queue. Therefore, a supervisor is a process manager. It will automatically start the queue worker in the background. As a result, it will automatically restart the worker if the worker exits unexpectedly.

What is a Balancing Strategy?

Laravel Horizon gives you three options;

  1. No balancing,
  2. Simple balancing
  3. And auto-balancing.

The default supervisor will have a single pool of workers processing all the running jobs. In comparison, simple balancing will create process pools for every queue.

Auto balancing will distribute the load on how busy the queue is. This process will continuously check the queues and balance them efficiently.

Key Features in Laravel Horizon

Simple Dashboard to Monitor the Queues | Fonseka Innovations
Simple Dashboard to Monitor the Queues

Auto balancing jobs

As mentioned above, Horizon will identify the workers and move them along the queues.

Dashboard and metrics

Horizon comes with a simple, beautiful Single Page Application (SPA).

As a result, you can manage queues and monitor jobs easily with real-time perspicacity. Not only that but also there are metrics you can keep an eye on.

On top of it, it is secure, and only the admins will be able to access it.

Code driven configuration

Horizon Configurations | Fonseka Innovations

The entire library is based on a simple code-driven configuration file. You can configure it according to your need, making it easier for you to manage.

Notifications

Laravel Horizon sends various types of notifications like Slack, SMS, Mail, Database, Broadcast notifications. And will notify you when it is overloaded with jobs. In either case, these types of notifications will help to improve queue capacity. Eventually, assisting the application to run smoother.

Conclusion

In conclusion, Horizon is a marvellous addition to the Laravel ecosystem. This solves many issues when it comes to handling multiple queues. As mentioned above, it has so much potential to help you expand your application.

At Fonseka Innovations, we have been building applications with Laravel since 2015. Throughout the years we have completed many projects which utilise Queues. All in all, Horizon has done a tremendous job by helping us manage and analyse queues. This not just helped us but also the projects we handle.

Given these points, if you have any innovating ideas or want to upgrade your application with Laravel, contact us.

About the author

Leave a Reply

Sign up to our newsletter.



We’d Love to talk about your next venture. Get in touch and we can start turning your idea into reality. Hope to hear from you soon!