1 00:00:01,260 --> 00:00:03,810 Our application is now in a pretty complete state. 2 00:00:03,930 --> 00:00:07,470 So now we're gonna start to think about how we could take this app and deploy it online. 3 00:00:07,920 --> 00:00:12,300 Let's first begin with a quick discussion about how our application is being executed right now on our 4 00:00:12,300 --> 00:00:13,590 local machine. 5 00:00:13,590 --> 00:00:16,490 So of course this is what is going on on your computer right now. 6 00:00:16,530 --> 00:00:21,390 We've got post comments query moderation and event plus they're all running on some very specific ports 7 00:00:21,930 --> 00:00:27,030 and each of them can reach directly out to the other services and send messages make requests whatever 8 00:00:27,040 --> 00:00:27,720 is required. 9 00:00:28,050 --> 00:00:31,890 It's very direct and simple communication between each of our different services. 10 00:00:31,980 --> 00:00:37,560 So how do we somehow take this same kind of structure make as few changes as possible and deploy it 11 00:00:37,620 --> 00:00:38,160 online. 12 00:00:39,000 --> 00:00:45,270 Well a very easy way to do this would be to go out to digital ocean or NWS Microsoft asa or whoever 13 00:00:45,270 --> 00:00:47,750 else and rent a virtual machine. 14 00:00:47,880 --> 00:00:51,660 Once we get that virtual machine we can transfer all of our services over to it. 15 00:00:51,660 --> 00:00:56,670 Like when I when I say transfer I really just mean copy our source code and then run each these services 16 00:00:56,730 --> 00:00:59,010 in the exact same way that we are doing right now. 17 00:00:59,250 --> 00:01:03,900 So we can have all the services communicating with each other by reaching out directly over local host 18 00:01:03,930 --> 00:01:08,200 and trying to access port four thousand four thousand one and so on. 19 00:01:08,210 --> 00:01:09,260 So this is definitely work. 20 00:01:09,260 --> 00:01:13,820 Without a doubt but as we start to really think through this scenario and think about how we would grow 21 00:01:13,820 --> 00:01:18,000 our application the future well life starts to get a little bit more challenging. 22 00:01:18,050 --> 00:01:19,400 Let me show you what I mean. 23 00:01:19,670 --> 00:01:25,620 Let's imagine for a second that our comment service right here is starting to become really overburdened. 24 00:01:26,000 --> 00:01:30,980 Maybe we have a tremendous number of users coming into our application and trying to create comments. 25 00:01:31,580 --> 00:01:36,470 And so at some point in time we might decide that we need to create a second or third instance of this 26 00:01:36,470 --> 00:01:39,520 comment server just to handle this additional demand. 27 00:01:39,770 --> 00:01:45,230 A very easy way to do that would be to say on the same virtual machine let's create two new copies of 28 00:01:45,230 --> 00:01:46,580 that common service. 29 00:01:46,590 --> 00:01:52,540 So we've got the original copy right here and two more over here whenever someone tries to create a 30 00:01:52,540 --> 00:01:53,100 comment. 31 00:01:53,140 --> 00:01:56,530 We can then load balance between these three different services. 32 00:01:56,530 --> 00:02:01,990 When I say load balance I essentially mean just randomize which server their incoming request goes to 33 00:02:03,470 --> 00:02:06,000 now there's a couple of challenges with this approach. 34 00:02:06,000 --> 00:02:10,680 First off these additional copies of the comment service would have to be allocated some Newport on 35 00:02:10,680 --> 00:02:11,520 this machine. 36 00:02:11,550 --> 00:02:15,990 So maybe we would have worked four thousand six and four thousand seven right there. 37 00:02:15,990 --> 00:02:21,690 That's relevant because remember art event bus needs to know the exact IP address and port of all the 38 00:02:21,690 --> 00:02:24,510 different services that it's going to send events to. 39 00:02:24,510 --> 00:02:29,640 So in other words as soon as we create these additional copies of the comment service over here we would 40 00:02:29,640 --> 00:02:33,680 have to open up our event bus code and as a matter of fact I can do that right now. 41 00:02:33,690 --> 00:02:37,020 Here's my event bus index dot J.S. file. 42 00:02:37,020 --> 00:02:41,250 We would have to find where we tried to take an event and send it off to all these other running services 43 00:02:41,610 --> 00:02:44,260 and we would have to add in two additional lines right here. 44 00:02:44,460 --> 00:02:48,580 Something like maybe four thousand and six and seven. 45 00:02:48,630 --> 00:02:55,410 Like so so if we follow this approach that we're going to start to couple or very directly tie the number 46 00:02:55,410 --> 00:03:00,930 of services that we are running with the actual implementation of our code if we ever decide to increase 47 00:03:00,960 --> 00:03:05,370 or decrease the number of comments service servers running at any given time we are going to have to 48 00:03:05,370 --> 00:03:09,180 make a change to our event bus code and deploy that change as well. 49 00:03:09,240 --> 00:03:12,230 And I bet as you can imagine that would probably not be too great. 50 00:03:13,630 --> 00:03:18,520 This whole scenario gets even more complicated if we see that the comments services right here that 51 00:03:18,520 --> 00:03:22,280 we added on are overburdening the one virtual machine we have. 52 00:03:22,300 --> 00:03:27,700 So let's imagine for a second that we decide to get a second virtual machine and run those two additional 53 00:03:27,700 --> 00:03:34,940 com and services on the second machine maybe they are still listed at North out port four thousand six 54 00:03:34,970 --> 00:03:35,890 and seven. 55 00:03:36,080 --> 00:03:41,630 But now the event bus not only needs to know or keep track of ports four thousand six and seven but 56 00:03:41,630 --> 00:03:46,400 it also is going to have to have some code to figure out how to reach out to this other virtual machine 57 00:03:46,850 --> 00:03:52,370 and eventually get access or send some events to the comment service right there and the CoM service 58 00:03:52,430 --> 00:03:53,900 right there. 59 00:03:53,900 --> 00:03:58,310 So once again we would have to open up our event plus file and rather than make your request to local 60 00:03:58,310 --> 00:04:06,310 host we'd have to put in the IP address of that other virtual machine like so and once again I bet as 61 00:04:06,310 --> 00:04:10,470 you can imagine that would be a really tedious finally. 62 00:04:10,490 --> 00:04:11,660 Let's imagine a scenario. 63 00:04:11,720 --> 00:04:13,250 One word just one more scenario here. 64 00:04:13,250 --> 00:04:18,470 Very quickly let's imagine for a second that our Web site is very popular at just certain times of the 65 00:04:18,470 --> 00:04:19,170 day. 66 00:04:19,250 --> 00:04:24,620 So maybe at 10:00 a.m. in the morning a lot of people come to our Web site and they start to create 67 00:04:24,620 --> 00:04:25,520 comments. 68 00:04:25,520 --> 00:04:29,840 And so at 10:00 a.m. in the morning we would want to have these additional copies of the comment service 69 00:04:29,840 --> 00:04:35,960 running but then maybe at 1:00 a.m. in the morning like at the dead of night maybe nobody is coming 70 00:04:36,020 --> 00:04:37,170 to our application. 71 00:04:37,220 --> 00:04:43,460 And so in order to save money on our hosting fees we might decide at 1 a.m. to temporarily shut down 72 00:04:43,520 --> 00:04:47,380 the second virtual machine and just say hey no one's coming to our website. 73 00:04:47,390 --> 00:04:49,610 We don't need those additional copies of the common service. 74 00:04:49,610 --> 00:04:54,370 So let's just temporarily temporarily turn all that stuff off now in this scenario. 75 00:04:54,370 --> 00:04:59,170 Once again the event boss needs to know that that second virtual machine is now dead and it should not 76 00:04:59,170 --> 00:05:01,590 attempt to send any events over there. 77 00:05:02,550 --> 00:05:07,020 Well to handle that we would have to come back over to our event bus and maybe add in some code and 78 00:05:07,020 --> 00:05:17,010 say something like if it is 1:00 a.m. or I should say if it is not 1:00 a.m. then go ahead and attempt 79 00:05:17,010 --> 00:05:25,630 to send the incoming events off to those other two services and once again has I'm sure you can imagine 80 00:05:26,020 --> 00:05:29,020 this is definitely not something we would ever want to write out right here. 81 00:05:29,020 --> 00:05:33,280 We would never want to say oh well if it's a certain time of the day let's try making requests over 82 00:05:33,280 --> 00:05:35,020 to these additional copies. 83 00:05:35,170 --> 00:05:39,800 So everything we're discussing now is really going down towards a very bad path. 84 00:05:39,900 --> 00:05:44,890 We are trying to put together this event bus and have it communicate between all these different services 85 00:05:45,160 --> 00:05:47,680 in a very direct and imperative fashion. 86 00:05:47,680 --> 00:05:52,240 We're trying to say he event bus you need to keep track of all the different services and you need to 87 00:05:52,240 --> 00:05:57,610 make sure that you always send every incoming event to every service that is running and you need to 88 00:05:57,610 --> 00:06:00,090 keep track of whether or not they are running. 89 00:06:00,160 --> 00:06:01,780 This is all just over the top. 90 00:06:01,780 --> 00:06:07,760 Complex way too confusing and there's probably no way we would be able to pull this off very easily. 91 00:06:07,760 --> 00:06:12,160 So I think it's pretty clear at this point that although what we have right now is working on our local 92 00:06:12,160 --> 00:06:14,620 machine it would probably not work in the long term. 93 00:06:15,010 --> 00:06:16,980 We need a better solution. 94 00:06:16,990 --> 00:06:21,130 We need something that's going to keep track of all the different services that are running inside of 95 00:06:21,130 --> 00:06:27,100 application has the ability to maybe create new copies of a service on the fly and make sure that we 96 00:06:27,100 --> 00:06:31,840 have something as well that can automatically figure out whether or not a service is running and whether 97 00:06:31,840 --> 00:06:36,110 or not we should maybe tried to make contact between two given services. 98 00:06:36,130 --> 00:06:40,570 So this is all going to lead us into a really big discussion in this section in all the next coming 99 00:06:40,570 --> 00:06:46,410 videos around two big open source technologies called Docker and Cuban eddies. 100 00:06:46,790 --> 00:06:48,090 They're going to take a pause right here. 101 00:06:48,100 --> 00:06:51,160 We're going to come back next video and have a quick discussion on Docker. 102 00:06:51,160 --> 00:06:54,880 We're going to get a little bit more familiar with it and then do the same thing with Cuban cities as 103 00:06:54,880 --> 00:06:55,150 well.