In this video we're going to get a better idea of the bull JFK Library and how it works with ready a
server and eventually understand how we're going to use it inside of our project.
OK so in this diagram this is not what we are doing with Bull.
This is a diagram of what people traditionally use bullet for.
So I just want you to understand a little bit of background about this library so in this imaginary
scenario right here we might have an application where a user can make a request with the intent to
convert some video file from one format such as an MP for to another format such as in K.B. if you are
not familiar with these file format for video.
No problem whatsoever is just an example.
All I mean to say is that this request in order to fulfill it.
We need a lot of processing power now rather than doing a conversion task like this on some immediate
web server.
We will very frequently Instead have some kind of worker server some separate machine some separate
container or something else inside of our app that is completely standalone and separate from the web
server.
The goal of this worker server is to have some actual video conversion process go on in this diagram
I'm showing just one worker server but we might very easily have multiple copies of this worker server
like so whenever someone makes the three incoming request right here to our Web server it's going to
include something called a job.
A job is really nothing more than a plain javascript object.
It describes some amount of processing that needs to be done on some particular thing all is going to
send this job object over to this read a server where Reddit is going to store this list of jobs then
each of these different worker servers are going to consistently pull this right a server and wait for
some job to appear as soon as some job shows up.
This worker is going to pull that job off do some processing on it and then send a message back over
to Red is to say that the processing is complete that's it.
That's what Bull is really used for.
Now just be really clear bull gets used both on this Web server over here and inside of each of these
worker servers as well so wool is really handling the entire process everything from setting up the
initial job to processing it to sending back some notification to say that the job is complete in this
respect.
This entire Reddit server and bull thing might actually seem kind of similar to our entire event processing
setup with Natsumi server and the note that streaming client that we are using.
They are somewhat similar in nature.
However we would not really want to use bold or doing the kind of event processing that you and I are
doing with the kind of async messaging between our different services.
The reason for that is that bull is simply not designed for it was designed for a one off little jobs
it's not really intended to be handling a vast or huge number of messages as in that streaming server
is OK.
Now just a little couple more pieces of terminology around bull.
So when we start to make useable just one additional piece terminology I want to add inside of here
we're going to create something called a queue a queue is essentially the main abstraction inside a
bowl a queue represents some series of messages that we want to queue up and eventually process over
time.
So we're going to use bull to specifically create a queue when we create the key we're also going to
specify exactly what we want to do with messages that are flowing through it and finally here's essentially
what's gonna be going on inside of our app.
So in our case we do not have any separate worker or server.
Everything is contained entirely inside the expiration service.
So for us this web server right here and the worker server over here are really just one single server
and we're really just making use of bull for this kind of delayed messaging aspect and to make sure
that if the expiration service ever goes down chances are the red server will not also go down.
Hopefully it won't.
Anyways so that's where you really using bull and readies for inside this project.
So now we have some big idea what's going on here.
Let's start to write out some code around bolt in the next video and I think you'll see pretty soon
that it's pretty easy and straightforward to make use of.