TubeSum ← Transcribe a video

Laravel Horizon: queue monitoring + configuration

Transcribed Jun 14, 2026 Watch on YouTube ↗
Intermediate 5 min read For: Laravel developers familiar with queues and Redis.
39.3K
Views
1.5K
Likes
97
Comments
5
Dislikes
4.0%
📈 Moderate

AI Summary

Laravel Horizon is a first-party package by the Laravel team that provides a beautiful dashboard for monitoring queue workers and a code-driven way to configure workers, balancing strategies, and processes. It only works with Redis-backed queues and is free and open source.

[00:00]
Introduction to Laravel Horizon

Horizon is a first-party package for monitoring and configuring queue workers, available since Laracon 2017.

[00:58]
Redis Requirement

Horizon only works with Redis-backed queues, not database or SQS queues.

[01:31]
Installation

Install via Composer: composer require laravel/horizon, then run php artisan horizon:install to publish assets and config.

[02:29]
Dashboard Overview

The dashboard shows pending, completed, silenced, and failed jobs. In production, access is restricted via an authorization gate.

[03:16]
Authorization Gate

Modify the Horizon service provider's gate to control who can view the dashboard in production.

[04:15]
Notifications

Horizon can send notifications via various channels when queues are overwhelmed or jobs take too long.

[05:16]
Configuration: Environments and Supervisors

Define per-environment worker counts, balancing strategies, and queues. Supervisors group processes with specific configurations.

[06:39]
Balancing Strategies

Auto balancing allocates processes based on queue depth. Options include auto, simple, and false. Autoscaling can be based on time or size.

[08:31]
Running Horizon

Start with php artisan horizon. This single command manages all workers. Use php artisan horizon:terminate for graceful shutdown during deployments.

[09:07]
Real-World Configuration Example

Example shows multiple supervisors with different timeouts and queues, e.g., short vs long jobs.

[13:04]
Useful Commands

Commands: status, list, supervisors, pause, continue, and terminate.

[14:11]
Reasons Not to Use Horizon

Only if using SQS as queue driver. Otherwise, Horizon is recommended for its power and convenience.

Laravel Horizon is a powerful, free, and open-source tool for managing Redis-backed queues, offering a dashboard and code-driven configuration. It simplifies queue management and is highly recommended for Laravel applications using Redis.

Clickbait Check

95% Legit

"Title accurately describes the video's content: queue monitoring and configuration with Horizon."

Mentioned in this Video

Tutorial Checklist

1 01:52 Run composer require laravel/horizon
2 02:11 Run php artisan horizon:install to publish assets and config
3 03:16 Modify the Horizon service provider's gate for production access
4 04:15 Configure notifications in the Horizon service provider
5 05:16 Edit config/horizon.php to define environments, supervisors, and balancing
6 08:37 Run php artisan horizon to start workers
7 10:12 Use php artisan horizon:terminate during deployments for graceful shutdown

Study Flashcards (10)

What queue driver does Laravel Horizon require?

easy Click to reveal answer

Redis

00:58

What command installs Laravel Horizon?

easy Click to reveal answer

composer require laravel/horizon

01:52

What command publishes Horizon assets and config?

easy Click to reveal answer

php artisan horizon:install

02:11

How do you restrict access to the Horizon dashboard in production?

medium Click to reveal answer

Modify the authorization gate in the Horizon service provider.

03:16

What is a supervisor in Horizon?

medium Click to reveal answer

A collection of processes (a group/bundle) with a specific configuration.

05:45

What are the three balancing strategy options in Horizon?

hard Click to reveal answer

auto, simple, and false

06:39

What command gracefully terminates Horizon during deployment?

medium Click to reveal answer

php artisan horizon:terminate

10:12

What command shows the status of Horizon?

easy Click to reveal answer

php artisan horizon:status

13:04

What command pauses all Horizon workers?

medium Click to reveal answer

php artisan horizon:pause

13:31

What command resumes paused Horizon workers?

medium Click to reveal answer

php artisan horizon:continue

13:54

💡 Key Takeaways

📊

Redis Requirement

Horizon only works with Redis, which is a key limitation.

00:58
🔧

Quick Dashboard Setup

In 30 seconds after install, you get a full queue monitoring dashboard.

02:29
🔧

Per-Environment Configuration

Horizon allows defining workers and balancing per environment, making it flexible.

05:16
🔧

Auto Balancing

Horizon can automatically allocate processes based on queue depth, optimizing throughput.

06:39
🔧

Graceful Termination

Using horizon:terminate during deployments prevents job loss and loads new code.

10:12

✂️ Creator Tools: Viral Hooks

AI-generated clip ideas for Shorts based on the transcript

Laravel Horizon: Free Queue Dashboard

45s

Shows how to get a full queue monitoring dashboard in 30 seconds, appealing to developers who want quick wins.

▶ Play Clip

Horizon Only Works with Redis

60s

Highlights a key limitation that sparks debate among developers using different queue backends.

▶ Play Clip

Configure Queue Workers in Code

60s

Demonstrates code-driven configuration for queue workers, a powerful feature that saves time and reduces errors.

▶ Play Clip

Auto-Scaling Queue Workers

60s

Explains how Horizon automatically allocates processes based on queue depth, optimizing resource usage.

▶ Play Clip

Graceful Deployment with Horizon

60s

Shows the critical 'terminate' command for zero-downtime deployments, a must-know for production apps.

▶ Play Clip

[00:00] welcome back to the what is Laravel series I'm 

[00:09] In Laravel Horizon got to be one of my favorite 

[00:20] party package so it's written and maintained by 

[00:26] 2017 I think so it's been around for a long time 

[00:33] beautiful dashboard for monitoring your Q workers 

[00:43] the number of workers the balancing strategy the 

[00:51] wrapped up and put into this Horizon configuration 

[00:58] backed cues so if you're using a database backed 

[01:05] that and so that's one maybe drawback but I pretty 

[01:12] coming from a different ecosystem this is very 

[01:19] I think it's called obon over in The Elixir world 

[01:26] probably sounds more familiar to you than Horizon 

[01:31] Horizon is free and open source so I'm going to 

[01:35] little bit more at the end I've got a very basic 

[01:40] browser we see it's just this invite a user and 

[01:47] job so this is the application that we're working 

[01:52] Laravel Horizon that's all it takes it's going to 

[01:58] can see that we are left with we're left with a 

[02:04] all of them but the first thing I am going to do 

[02:11] going to do it's going to publish the assets the 

[02:16] we'll go over the configuration here in a second 

[02:22] matter of 30 seconds here we now have a full on 

[02:29] dashboard monitoring metrics pending jobs 

[02:36] of this lives inside of our application it's 

[02:43] so all of this all of this chrome all of these 

[02:49] Horizon package now it's inside of our app now 

[02:55] where everybody can see it in local development 

[03:01] and you have to modify the authorization gate to 

[03:08] is kind of important that's kind of what you 

[03:12] we'll dive in a little bit deeper to modify the 

[03:16] service provider which has been published into our 

[03:21] of our app providers directory that was put there 

[03:27] see is this looks interesting but we're going to 

[03:32] attention we're going to jump down here to this 

[03:39] great put some people's emails here and we'll 

[03:43] could put Aaron example.com please send me some 

[03:50] production if if you aren't um if you don't have a 

[03:58] I think you can say equals null and then you don't 

[04:04] that you want down here it's just a function you 

[04:08] is able to view the Horizon dashboard scrolling 

[04:15] also comes with notifications so if a queue is 

[04:21] really long time to complete you can just route 

[04:28] that all you have to do is put the information in 

[04:34] have to set up your SMS provider but this uses 

[04:39] it's pretty it's pretty straightforward let's look 

[04:45] configuration file I have to warn you it's pretty 

[04:49] configure it exactly how we want I am not however 

[04:54] much right here but I can show you uh a few of 

[05:00] dashboard from a subdomain so if you don't want 

[05:05] or o or admin dot you could do that you can also 

[05:11] have to be SL Horizon it can be SL whatever else 

[05:16] here to show you this environments key so in this 

[05:22] got local and this is where you get to Define per 

[05:29] what the balancing strategy is what cues are 

[05:35] got something called supervisor one doesn't need 

[05:40] could be called anything you want we'll leave 

[05:45] just means um a collection of processes a group a 

[05:52] reason you can have multiple is let's say you want 

[06:00] this configuration you just want it to process the 

[06:08] a high and a low q and you need more throughput 

[06:13] great place to do that in fact let's go ahead and 

[06:19] because we don't super care about it and then 

[06:24] process is in fact just process the low Q that's 

[06:32] is fine I don't really care about that so much 

[06:39] default is auto which is good I like that I think 

[06:46] false is an option but since Auto is the default 

[06:52] do is this is going to allocate processes based on 

[06:59] slammed and your default queue is empty it's going 

[07:05] high Q you can say hey don't don't leave me 

[07:13] the Min the minimum number of processes working 

[07:19] 13 over to the high q but leave two on to process 

[07:27] I think it's Auto scaling strategy let's I think 

[07:35] strategy that is correct you've got time and 

[07:43] take a really long time you can say actually let's 

[07:49] take to empty out the queue instead of balancing 

[07:56] that if you want and then down here it's going 

[08:02] at a time in our case we're saying one process 

[08:09] you can configure to match your exact setup and 

[08:17] absolutely hammering your server um this is where 

[08:24] this in Version Control and then putting all of 

[08:31] processes but for you to start it all you have 

[08:37] go ahead and do that right now so if we run PHP 

[08:44] do now it is running under the hood it's running 

[08:50] running up to 20 processes watching those cues 

[08:58] have to keep alive this is it I'm going to show 

[09:02] show you configuration from a real app that I've 

[09:07] this is the configuration from an app that I 

[09:11] short supervisor long and the connection one is on 

[09:16] sense timeout is 90 timeout is 1,200 and you see 

[09:24] and this one processes the long and the scrapers 

[09:30] we give it a much longer time out and a and just 

[09:36] have a lot higher throughput starting Horizon is 

[09:42] this is the command that you would um that you 

[09:48] Forge it's a simple toggle you just say keep 

[09:53] you'd need to set up actual supervisor to make 

[10:00] command goes down all of your key workers go down 

[10:06] terminate this gracefully when you are deploying 

[10:12] by saying PHP Artisan Horizon terminate so you 

[10:21] and this is really important when you deploy new 

[10:26] is going to put your application in memory and 

[10:30] in your deploy script is Horizon colon terminate 

[10:36] and it's going to load your new application into 

[10:42] over here I'm just going to run PHP artisan and I 

[10:52] invite yeah PHP Artisan invite users and this 

[11:01] should start to see that working so this this 

[11:08] calling out to an API or something but you can 

[11:13] and if we look in the browser if we look in the 

[11:19] on the default and we've got some failed jobs so 

[11:26] well this failed to send in fact let me just let 

[11:32] the dashboard it's going to put it back in the 

[11:36] get this the retry down here it shows that it's 

[11:42] and kill let's kill Horizon again and hop back to 

[11:49] that it is inactive and we're going to come over 

[11:57] let's change the max process is to Let's Go Crazy 

[12:04] this again I bet those are going to turn through 

[12:13] and it gives us a little bit it gives us a little 

[12:18] can see we've got 800 700 um jobs in this default 

[12:25] only your cues but also the supervisors that are 

[12:32] have the one supervisor so that checks out that 

[12:37] churning through these jobs now you can check the 

[12:43] of information if you have a bunch of jobs that 

[12:48] right here you can add those to silence jobs and 

[12:52] packages running jobs or um notifications or 

[12:58] see you can put you can put those in the silenced 

[13:04] before we go PHP Artisan Horizon let's start 

[13:09] is good then you can say list and this will show 

[13:15] running you could also do PHP Artisan supervisors 

[13:24] detail about each individual supervisor you can 

[13:31] getting totally hammered by something you can say 

[13:36] at the moment so you can log in or you can ssh 

[13:43] command and you could potentially pause hundreds 

[13:50] broken it's not resume it's continue after you 

[13:54] go back to work people and finally remember the 

[14:03] PHP aren Horizon terminate there you go and 

[14:11] time to terminate this video pretty proud of that 

[14:17] Horizon I think potentially the best reason to not 

[14:24] Q driver and therefore you can't use Horizon if 

[14:31] don't see a good reason not to use it frankly free 

[14:38] powerful makes your life extremely convenient 

[14:43] video about Laravel octane in the same style 

⚡ Saved you time reading this? Transcribe any YouTube video for free — no signup needed.