1 00:00:01,030 --> 00:00:04,750 In this video we're going to get a better idea of the bull JFK Library and how it works with ready a 2 00:00:04,750 --> 00:00:09,170 server and eventually understand how we're going to use it inside of our project. 3 00:00:09,170 --> 00:00:12,340 OK so in this diagram this is not what we are doing with Bull. 4 00:00:12,370 --> 00:00:15,970 This is a diagram of what people traditionally use bullet for. 5 00:00:15,970 --> 00:00:20,480 So I just want you to understand a little bit of background about this library so in this imaginary 6 00:00:20,480 --> 00:00:26,060 scenario right here we might have an application where a user can make a request with the intent to 7 00:00:26,060 --> 00:00:32,900 convert some video file from one format such as an MP for to another format such as in K.B. if you are 8 00:00:32,900 --> 00:00:35,090 not familiar with these file format for video. 9 00:00:35,120 --> 00:00:37,380 No problem whatsoever is just an example. 10 00:00:37,400 --> 00:00:40,190 All I mean to say is that this request in order to fulfill it. 11 00:00:40,190 --> 00:00:46,380 We need a lot of processing power now rather than doing a conversion task like this on some immediate 12 00:00:46,380 --> 00:00:47,370 web server. 13 00:00:47,400 --> 00:00:52,380 We will very frequently Instead have some kind of worker server some separate machine some separate 14 00:00:52,380 --> 00:00:57,420 container or something else inside of our app that is completely standalone and separate from the web 15 00:00:57,420 --> 00:00:58,410 server. 16 00:00:58,440 --> 00:01:05,030 The goal of this worker server is to have some actual video conversion process go on in this diagram 17 00:01:05,090 --> 00:01:09,740 I'm showing just one worker server but we might very easily have multiple copies of this worker server 18 00:01:10,250 --> 00:01:16,310 like so whenever someone makes the three incoming request right here to our Web server it's going to 19 00:01:16,310 --> 00:01:18,530 include something called a job. 20 00:01:18,770 --> 00:01:22,490 A job is really nothing more than a plain javascript object. 21 00:01:22,520 --> 00:01:28,650 It describes some amount of processing that needs to be done on some particular thing all is going to 22 00:01:28,710 --> 00:01:36,190 send this job object over to this read a server where Reddit is going to store this list of jobs then 23 00:01:36,220 --> 00:01:40,600 each of these different worker servers are going to consistently pull this right a server and wait for 24 00:01:40,600 --> 00:01:43,780 some job to appear as soon as some job shows up. 25 00:01:43,780 --> 00:01:48,490 This worker is going to pull that job off do some processing on it and then send a message back over 26 00:01:48,490 --> 00:01:52,710 to Red is to say that the processing is complete that's it. 27 00:01:52,740 --> 00:01:54,250 That's what Bull is really used for. 28 00:01:54,300 --> 00:01:59,880 Now just be really clear bull gets used both on this Web server over here and inside of each of these 29 00:01:59,880 --> 00:02:06,190 worker servers as well so wool is really handling the entire process everything from setting up the 30 00:02:06,190 --> 00:02:11,840 initial job to processing it to sending back some notification to say that the job is complete in this 31 00:02:11,840 --> 00:02:12,510 respect. 32 00:02:12,530 --> 00:02:17,360 This entire Reddit server and bull thing might actually seem kind of similar to our entire event processing 33 00:02:17,360 --> 00:02:21,470 setup with Natsumi server and the note that streaming client that we are using. 34 00:02:21,680 --> 00:02:23,410 They are somewhat similar in nature. 35 00:02:23,480 --> 00:02:28,190 However we would not really want to use bold or doing the kind of event processing that you and I are 36 00:02:28,190 --> 00:02:32,230 doing with the kind of async messaging between our different services. 37 00:02:32,250 --> 00:02:37,940 The reason for that is that bull is simply not designed for it was designed for a one off little jobs 38 00:02:38,970 --> 00:02:43,950 it's not really intended to be handling a vast or huge number of messages as in that streaming server 39 00:02:43,950 --> 00:02:45,850 is OK. 40 00:02:45,890 --> 00:02:49,590 Now just a little couple more pieces of terminology around bull. 41 00:02:49,610 --> 00:02:53,960 So when we start to make useable just one additional piece terminology I want to add inside of here 42 00:02:54,440 --> 00:02:59,510 we're going to create something called a queue a queue is essentially the main abstraction inside a 43 00:02:59,510 --> 00:03:05,680 bowl a queue represents some series of messages that we want to queue up and eventually process over 44 00:03:05,680 --> 00:03:06,020 time. 45 00:03:06,470 --> 00:03:10,910 So we're going to use bull to specifically create a queue when we create the key we're also going to 46 00:03:10,910 --> 00:03:17,040 specify exactly what we want to do with messages that are flowing through it and finally here's essentially 47 00:03:17,040 --> 00:03:19,190 what's gonna be going on inside of our app. 48 00:03:19,230 --> 00:03:22,410 So in our case we do not have any separate worker or server. 49 00:03:22,410 --> 00:03:25,940 Everything is contained entirely inside the expiration service. 50 00:03:25,950 --> 00:03:31,110 So for us this web server right here and the worker server over here are really just one single server 51 00:03:31,740 --> 00:03:37,050 and we're really just making use of bull for this kind of delayed messaging aspect and to make sure 52 00:03:37,050 --> 00:03:41,760 that if the expiration service ever goes down chances are the red server will not also go down. 53 00:03:41,790 --> 00:03:42,420 Hopefully it won't. 54 00:03:42,420 --> 00:03:47,200 Anyways so that's where you really using bull and readies for inside this project. 55 00:03:47,210 --> 00:03:49,870 So now we have some big idea what's going on here. 56 00:03:49,890 --> 00:03:53,400 Let's start to write out some code around bolt in the next video and I think you'll see pretty soon 57 00:03:53,400 --> 00:03:55,620 that it's pretty easy and straightforward to make use of.