---
title: '1. Laravel Horizon - Monitor Redis Queue Jobs'
source: 'https://youtube.com/watch?v=DjbQm4IZCYQ'
video_id: 'DjbQm4IZCYQ'
date: 2026-06-15
duration_sec: 0
---

# 1. Laravel Horizon - Monitor Redis Queue Jobs

> Source: [1. Laravel Horizon - Monitor Redis Queue Jobs](https://youtube.com/watch?v=DjbQm4IZCYQ)

## Summary

This video introduces Laravel Horizon, a package for monitoring Redis queues in Laravel. It covers installation, configuration, and demonstrates how to process queued notifications using Horizon's dashboard.

### Key Points

- **Introduction to Laravel Horizon** [00:00] — Laravel Horizon is an official package for Laravel that provides a beautiful dashboard and configuration for Redis queues.
- **Installation** [00:21] — Install via Composer: composer require laravel/horizon
- **Creating a Notification** [01:00] — Create a notification (UserNotification) that sends an email to a user.
- **Making Notification Queuable** [02:22] — Implement ShouldQueue interface on the notification to move it to a queue.
- **Configuring Queue Driver** [02:56] — Set QUEUE_CONNECTION=redis in .env file to use Redis as the queue driver.
- **Installing Predis** [03:22] — Install Predis via Composer: composer require predis/predis
- **Setting Redis Client** [04:08] — Set REDIS_CLIENT=predis in .env file to use Predis instead of phpredis.
- **Installing Horizon Assets** [05:32] — Run php artisan horizon:install to publish assets, config, and service provider.
- **Horizon Configuration** [06:00] — The config/horizon.php file contains settings like path, middleware, environments, and process counts.
- **Horizon Service Provider** [07:08] — The HorizonServiceProvider has a gate method to restrict access to the dashboard to specific users.
- **Redis Prefix** [08:15] — Horizon uses a prefix (default: 'horizon:') for Redis keys, configurable via HORIZON_PREFIX env variable.
- **Starting Horizon** [09:32] — Run php artisan horizon to start processing queues. It replaces php artisan queue:work.
- **Handling Failed Jobs** [10:18] — Horizon dashboard shows failed jobs and allows retrying them with a button.
- **Configuring Processes and Retries** [11:29] — In config/horizon.php, set 'processes' and 'tries' per environment. Changes require restarting Horizon.
- **Balance Strategy** [13:18] — Balance can be 'simple' (even split) or 'auto' (adjusts based on workload). 'auto' is recommended.

### Conclusion

Laravel Horizon provides a powerful dashboard and configuration for managing Redis queues in Laravel. It simplifies monitoring and scaling queue workers, with features like failed job retries and auto-balancing.

## Transcript

welcome to bed films and let me
introduce you with an official package
of level which is called larval horizon
this is a great package and let's first
quickly get started with this package by
using this composer command to have this
inside our level application so he'll is
a fresh installation of lateral and I
will say composer require level /
horizon-- so this package is very useful
when you are using cues with cue driver
as readies so it provides a beautiful
dashboard and some configuration for
your level power red excu so very
important thing is you need to use cue
driver as reddit's this package provides
this kind of cool dashboard where you
can have number of jobs number of fill
job number of processes and you can also
retry some field job but let's first see
why we need this kind of package so yeah
it is installed so here I am and I will
create a simple notification so make
notification called user notification
and this notification is just a simple
notification which is sending an email
to a user so I will open web dot PHP
file and here I will go and send this
notification to our user so find with
the idea of one and notify user notify
with new notify user notification okay
so we need to grab this user also and at
last we are going to return simply done
so I have already configured my dot e
and we file so with the test database
and inside our test database we also
have a one user with the ID of 1 this
means if I start the server and if I go
to localhost 8000
you will see it is taking long time and
by the way I also have configured this
mail trap on our dot env file so here
you can see I
have configured so it always take time
so even if I have one small refresh it
take time to send an email because it's
processing the sending part email
sending part and now we have the to
email we can make this sending of email
or sending notification in a queue so I
will open notify user and here we just
need to say simply implementing so like
implements should queue just by using
this we have now moved this notification
into queue
okay so if i refresh this page still it
is taking time because now if I go and
on this dot Ian we file I said that
queue connection is sync so this means
it is thinking the queue we need to
change it to red is because now we want
the queue to be used by Redis once more
restart the server and refresh this page
and you can see instantly it's giving
error because level by default uses PHP
Redis
so either you can install PHP Redis or P
Redis so once more go to level
documentation and on this documentation
you can search for Redis and on this
Redis part you can see we can you either
use red Pierre IDs or PHP IDs but I
personally like P Redis and it is very
easy because it is also given here so
you need to run this command composer
command so let's stop the server run
this composer command finally our peer
Eddy's is installed so now once more we
can start the server and go to localhost
8080 in this error but why we are
getting this error because we need to
tell to level that level don't use PHP
Redis you need to use the period is how
we can do that for that we need to go to
the configuration of Redis so let's go
and here inside config we have a
spot inside this database at the last we
can see we have this red spot and ready
is using PHP Redis you can simply define
it on env files so instead of doing this
from here I will go here and define
Redis client so like here right if
client is P Redis very nice we have made
changes in dot E and V file so we need
to restart the server and one more try
and this time with no error and super
quickly no delay we have moved our email
into this queues but once more if I
delete everything from here refresh this
page you can see we don't have any email
this means our queues are not processed
so how we can generally process so we
can say PHP artisan queue work and then
if I do this yes now I'm having the
email because now these notification are
processed that good but now comes our
level horizon so let's now continue our
installation of level horizon so we have
installed it via this composer command
but we need to run this command to
install its effects so I will stop this
queue worker and then I will say PHP
artisan horizon : installed so it has
done three things published the service
provider some assets and the
configuration so let's start with the
configuration on this config folder we
have this horizontal Asian and in this
horizontal figuration the unique thing
you can see we have this path which is
horizon this means if you have server
running you can simply go on localhost
8004 as on and then you can see you have
a cool dashboard and instantly you can
see it has picked two job because
previously we have ran two jobs so
without using queue worker and this
means so we can simply see the recent
job and other
things like monitor and matrix but from
where this dashboard came from the UI
came from so you can see we have
published the effects so we have the
effects inside public vendor assets this
is just for all the UI it is made
overview GS and this is because of that
one more thing we have published is
service provider which is inside app
provider and horizontals provider so in
this horizontal provider we have a boot
method and a gate method so you can see
generally we can access this horizon--
route even if I am not logged in but
when you want to give access to this
horizon dashboard just to one or two
people you can just define the email
here like this and then the user with
this email ID when they are logged in
then only they can able to access this
route otherwise they will get 404 that's
a simple configuration kind of things
are related to resin but more is inside
this horizon-- configuration file so we
have seen that part next is it is going
to use the connection so default
connection of Redis and this by default
prefix everything related to your
application with horizontal in' if you
want to make changes in this you need to
give this information inside your dot
env file and we can prove this also so I
will go here and I will say red is CLI
and if you don't have ready you can
simply say brew install Redis if you are
using Mac and for window you can I think
you can simply find it so ready CLI and
in this you can simply say keys and X
tricks you can see we have this horizont
notifier user and last snapshot this is
just because of this horizon and this is
actually the prefix we have we are
talking about here that's cool there
middleware and wait time then the most
important thing here is this environment
so we have this production environment
and local end moment so let's talk about
these things first so what about the
previous two jobs we have put inside the
queue so even if I go on localhost 8080
processed it processed the notification
but we are not getting any email inside
our mail trap so you can see we don't
have any email say it was eight minutes
ago okay so to process the queue on this
Redis with the help of horizon what you
need to do you need to run the command
which is PHP artisan horizon-- so it's
just like you run command PHP artisan
queue work similar to that we are using
PHP artisan horizont so horizont started
successfully and this means now we can
see it is now converted to active so our
dashboard is active cool so now because
it is active you can see now but one
previous notification is processed and
once more if I clear this and refresh
this page you can see now it says the
for in the past one in the minute and it
is now processed so it is very very cool
and you can actually check the failed
job so how we can check the failed job
how we can fail a job one crazy thing I
am going to do here is I'm going to say
firstly inside tinker so PHP artisan
tinker and I will say hey tinker create
50 user for me ok so now we have a 50
user inside our database and this means
now I can simply say grab me every user
and for each user notify user very nice
so let's see what's going to happen this
is going to be very very interesting so
now if I say refresh this page instantly
we are getting done but now we have 50
five jobs 54 now and five for the
previous one so you can see it says 45
jobs are in queue it's currently
actually working four and then eight are
failed because we have too much of jobs
and we have just three processes so
while this is processing let's go once
again to the horizon-- configuration and
you can see we can define the number of
process so currently we have three
processes and we have one retry
that's why failed job comes here because
they are just retried once so if I go to
the failed jobs you can see we have a
retry button so if I click here it's now
read trying this so that's cool and now
totally we have 35 and still four are
inside the processes now total zero and
if i refresh out of 50 40 jobs are
failed this is not good so you can see
we just have 10 email here so once again
clear this and now what I'm going to do
I'm going to make processes as 10 and
retry as 5 and whenever you made change
in horizontal you need to restart the
horizon this is very important whenever
you made changes in horizon-- or even in
your notification you need to make
restart this horizont process ok
so for the sake of safety nets I'm also
going to restart the server okay so we
have 56 jobs here 40 are failed and now
because we have restarted it's picked up
that we are working with 10 processes
cool refresh this page and now we have
form 0 7 tasks and after completion you
can see we have total 75 fail previously
it was 40 and now it is 75 that means 35
still feeling okay one more
configuration you can do is like here it
is defined that yeah so you can give the
balance as simple it is given balance as
simple so you can also say Auto so
simple is very simple which configure it
splits incoming job evenly into the
process but if you say auto auto
strategy adjust the number of vocal
processors per cube based on the current
workload ok so I am going to make it
auto and then because we have made
changes let's restart the horizon-- and
now I'm going to say refresh and
refreshing with that and now we have 168
jobs so 50 more is now added so now we
have 1 1 10 field job is still having 35
failing but the processes took less time
to processing all these queues so in
that way you can actually define the
last one which is false which is just a
simple first-come first out kind of
things on notifications or in the queues
so this is a simple demonstration of how
you can use level horizon and how you
can configure with different
configurations there are some more
things on this horizontal continue or
even terminate the horizon simply but in
the next episode we are going to see how
we can actually deploy this horizon
error actually use this horizon on a
server are you going to server with the
supervisor as our client to run the PHP
artisan horizon command ok if you liked
this episode please give it a thumbs up
and comment your views about level
horizont is it a good when you have used
and what makes you to use this package
and don't forget to subscribe to this
channel and like which films on Facebook
Twitter Instagram LinkedIn and feeble
meet in the next episode till then good
bye
