1 00:00:00,180 --> 00:00:04,800 ‫All right, guys, so I have visual studio code here, the minimum requirements are going to have no 2 00:00:04,800 --> 00:00:08,850 ‫JASE'S installed and visual studio code and you can start working on this stuff right there. 3 00:00:09,480 --> 00:00:14,400 ‫So I'm going to go ahead and open and brand new folder that's going to create JavaScript Playground. 4 00:00:14,430 --> 00:00:15,720 ‫I'm going to call it Sharding. 5 00:00:16,320 --> 00:00:17,850 ‫Right and Open. 6 00:00:18,360 --> 00:00:24,900 ‫And what I'm going to do is create a file called Indexed, I guess the best file ever. 7 00:00:25,590 --> 00:00:31,050 ‫Then let's initialize and because it's a new project. 8 00:00:31,050 --> 00:00:31,410 ‫Right. 9 00:00:31,470 --> 00:00:32,370 ‫So MBM. 10 00:00:32,640 --> 00:00:34,220 ‫And that's why I mean, shut up. 11 00:00:34,230 --> 00:00:34,950 ‫I know what I'm doing. 12 00:00:34,950 --> 00:00:37,620 ‫Just create a package to Jayson's called Sharding. 13 00:00:38,040 --> 00:00:38,790 ‫Sweet. 14 00:00:39,270 --> 00:00:39,670 ‫All right. 15 00:00:39,690 --> 00:00:49,230 ‫So now remember, guys, we did a tutorial on how to work with postscripts from No Jass using a very 16 00:00:49,230 --> 00:00:51,290 ‫beautiful library called PGT. 17 00:00:51,390 --> 00:00:51,740 ‫Right. 18 00:00:51,960 --> 00:00:56,520 ‫And we're going to use the exact same library to connect to the database as it was initially. 19 00:00:57,340 --> 00:01:03,080 ‫And what we're building here is like we're building a Web application that have a post and a get right 20 00:01:03,180 --> 00:01:09,210 ‫post will create a new URL shortener, will shorten the oil, give any oil and get will. 21 00:01:09,210 --> 00:01:13,650 ‫Given that you will code, the shortest URL will give me that long URL. 22 00:01:13,750 --> 00:01:15,040 ‫It's very simple stuff, right. 23 00:01:15,300 --> 00:01:15,780 ‫So let's go ahead. 24 00:01:15,780 --> 00:01:17,740 ‫And obviously we're going to need express. 25 00:01:17,910 --> 00:01:26,550 ‫So again, do require express spun up that express beautiful stuff after get going to do something with 26 00:01:26,550 --> 00:01:27,300 ‫this thing. 27 00:01:27,310 --> 00:01:28,890 ‫Request response. 28 00:01:29,910 --> 00:01:32,450 ‫That's to get command post. 29 00:01:32,460 --> 00:01:34,290 ‫That's the post command. 30 00:01:34,290 --> 00:01:36,360 ‫That's what we will actually write. 31 00:01:36,650 --> 00:01:37,150 ‫Right. 32 00:01:37,200 --> 00:01:40,560 ‫Our beautiful beautiful. 33 00:01:41,130 --> 00:01:42,130 ‫You are shortener. 34 00:01:42,390 --> 00:01:44,630 ‫OK, and here's what we want. 35 00:01:44,640 --> 00:01:46,680 ‫We want the database's guys. 36 00:01:46,680 --> 00:01:51,390 ‫So the database is called const client. 37 00:01:51,450 --> 00:01:51,830 ‫Right. 38 00:01:52,110 --> 00:01:54,930 ‫And let's use this structure assignment. 39 00:01:54,930 --> 00:01:57,000 ‫I know sometimes it's confusing. 40 00:01:57,000 --> 00:01:57,450 ‫Right. 41 00:01:57,720 --> 00:02:01,920 ‫This is essentially called the library for the Postgres database called PJI. 42 00:02:01,920 --> 00:02:02,300 ‫Right. 43 00:02:02,360 --> 00:02:08,370 ‫You can either do it this way or just do the destructo assignment, whatever rocks your boat. 44 00:02:08,970 --> 00:02:11,220 ‫That's that's exactly the same. 45 00:02:12,200 --> 00:02:12,830 ‫All right. 46 00:02:12,870 --> 00:02:15,420 ‫And we have the client. 47 00:02:15,720 --> 00:02:16,890 ‫What do we do with a client? 48 00:02:16,890 --> 00:02:18,420 ‫We need to spin up multiple. 49 00:02:18,630 --> 00:02:20,190 ‫We have to spin up three clients. 50 00:02:20,190 --> 00:02:21,530 ‫So here's what we're going to do. 51 00:02:21,540 --> 00:02:27,390 ‫So we're going to create a client's right, Jason object and the JSON object. 52 00:02:27,390 --> 00:02:35,460 ‫The key will be the port, because I want to play this trick here where the key is the port and the 53 00:02:35,610 --> 00:02:38,640 ‫Jason value is the configuration here. 54 00:02:38,900 --> 00:02:42,960 ‫So so how do we do this as a five, four, three, two? 55 00:02:42,970 --> 00:02:44,730 ‫That's the first client. 56 00:02:45,090 --> 00:02:48,750 ‫And that value is new client. 57 00:02:48,750 --> 00:02:52,400 ‫And then you pass in that beautiful configuration. 58 00:02:52,410 --> 00:02:53,740 ‫So what do we do there? 59 00:02:53,740 --> 00:02:56,790 ‫Then we put the right to say, Mac. 60 00:02:58,570 --> 00:03:04,480 ‫Again, guys, I have done through all that stuff you want a detailed story about the Polska self, 61 00:03:04,630 --> 00:03:08,660 ‫I'm going to reference that video, but this will be just skimming through this stuff, right? 62 00:03:09,010 --> 00:03:12,190 ‫So port obviously, port five, four, three, two. 63 00:03:13,210 --> 00:03:14,770 ‫And what else? 64 00:03:14,770 --> 00:03:26,020 ‫User as well as to what is also Chris and database is also Postgres. 65 00:03:26,590 --> 00:03:27,760 ‫I'm just lazy guys. 66 00:03:27,760 --> 00:03:29,110 ‫Just use the same. 67 00:03:29,110 --> 00:03:30,360 ‫I have to do that thing right. 68 00:03:30,580 --> 00:03:33,670 ‫And then that's one client. 69 00:03:33,670 --> 00:03:35,650 ‫We need other two clients. 70 00:03:35,660 --> 00:03:36,030 ‫Right. 71 00:03:37,060 --> 00:03:43,470 ‫The client running on Port three three and the client running on four. 72 00:03:43,900 --> 00:03:45,130 ‫How about that, guys? 73 00:03:45,460 --> 00:03:49,600 ‫I think we're good here so that a bunch of clients. 74 00:03:49,600 --> 00:03:49,960 ‫Right. 75 00:03:50,620 --> 00:03:51,970 ‫Still, we didn't connect them. 76 00:03:51,970 --> 00:03:52,930 ‫How do we connect? 77 00:03:53,020 --> 00:03:53,350 ‫Right. 78 00:03:53,440 --> 00:03:55,150 ‫So we need a function called connect here. 79 00:03:55,810 --> 00:03:59,850 ‫So that's because I'm going to use the async away. 80 00:03:59,860 --> 00:04:07,480 ‫Tears are going to do a function called conduct function function if I can spell connect. 81 00:04:07,720 --> 00:04:14,530 ‫And what we're going to do essentially is just call this function immediately and then connect those 82 00:04:14,530 --> 00:04:14,890 ‫guys. 83 00:04:14,900 --> 00:04:15,170 ‫Right. 84 00:04:15,430 --> 00:04:21,850 ‫So we can do like fancy loop or just the old school way where just like literally five, four, three, 85 00:04:21,850 --> 00:04:30,430 ‫two, dot connect, connect those TCP connection, establish those beautiful deep connections. 86 00:04:30,730 --> 00:04:31,090 ‫All right. 87 00:04:31,780 --> 00:04:38,800 ‫I try catch would be nice here but I'm trying to go through the video real quick so that will actually 88 00:04:38,800 --> 00:04:40,930 ‫give us the kinds of connections. 89 00:04:41,260 --> 00:04:42,330 ‫Beautiful stuff. 90 00:04:42,700 --> 00:04:45,100 ‫What's next guys we need. 91 00:04:45,250 --> 00:04:49,390 ‫The next thing is let's start with the writing aspect of it. 92 00:04:50,260 --> 00:04:50,580 ‫Right. 93 00:04:50,580 --> 00:04:54,130 ‫So writing a new row. 94 00:04:54,130 --> 00:04:54,460 ‫Right. 95 00:04:54,460 --> 00:04:56,400 ‫So I'm going to write to the database again. 96 00:04:56,680 --> 00:04:57,700 ‫So how do we write? 97 00:04:57,700 --> 00:04:57,990 ‫Right. 98 00:04:58,000 --> 00:05:02,950 ‫So posting let's assume I'm going to get the all of that query parameter. 99 00:05:02,950 --> 00:05:03,350 ‫How are we going to. 100 00:05:03,580 --> 00:05:07,120 ‫I made a video about the query parameters versus resources for you. 101 00:05:07,150 --> 00:05:07,890 ‫Interested that. 102 00:05:08,020 --> 00:05:08,860 ‫Go watch that video. 103 00:05:08,860 --> 00:05:13,990 ‫I'm going to sit here, but are you going to request dot query parameter Dorte URL. 104 00:05:13,990 --> 00:05:17,170 ‫So just give that oil and once you get that you URL. 105 00:05:17,170 --> 00:05:17,890 ‫Here's the thing. 106 00:05:17,920 --> 00:05:26,230 ‫We need to consistently hash this thing, hash this to get a port, get that port. 107 00:05:26,530 --> 00:05:28,450 ‫So how do we do this. 108 00:05:28,480 --> 00:05:30,900 ‫This is the consistent hash that we talked about guys. 109 00:05:31,180 --> 00:05:33,770 ‫So let's do that. 110 00:05:33,850 --> 00:05:39,670 ‫So there is a library called Const Consists Tent. 111 00:05:40,580 --> 00:05:46,950 ‫Hash, and I think it's called literally consistent hash. 112 00:05:47,000 --> 00:05:48,640 ‫I think it's called that, right? 113 00:05:48,650 --> 00:05:50,900 ‫So it's called consistent dash hash. 114 00:05:50,900 --> 00:05:51,770 ‫So that's what it's called. 115 00:05:51,770 --> 00:05:52,030 ‫Right. 116 00:05:52,190 --> 00:05:58,220 ‫And then when you do that, what you essentially want to do is create a hash ring that the one we just 117 00:05:58,220 --> 00:05:58,720 ‫talked about. 118 00:05:58,730 --> 00:05:58,910 ‫Right. 119 00:05:58,920 --> 00:06:01,440 ‫So it's like a hash tag of how many nodes in this case. 120 00:06:01,580 --> 00:06:02,510 ‫We have three nodes. 121 00:06:02,600 --> 00:06:03,740 ‫It's really easy stuff. 122 00:06:03,740 --> 00:06:06,100 ‫So I'm going to create a hash ring. 123 00:06:06,110 --> 00:06:10,060 ‫Each are equal new consistent hash. 124 00:06:10,070 --> 00:06:10,420 ‫Right. 125 00:06:10,750 --> 00:06:12,440 ‫So we're going to create a hash ring. 126 00:06:12,470 --> 00:06:12,790 ‫Right. 127 00:06:12,800 --> 00:06:14,480 ‫And then we start adding our nodes. 128 00:06:14,480 --> 00:06:14,700 ‫Right. 129 00:06:14,930 --> 00:06:17,170 ‫But we're not going to get Intellisense, I think. 130 00:06:17,170 --> 00:06:17,960 ‫Yeah, that's what I thought. 131 00:06:17,990 --> 00:06:23,050 ‫So let's go ahead and just install all that stuff, because we have done a lot of stuff and we have 132 00:06:23,060 --> 00:06:24,620 ‫never installed any of that stuff. 133 00:06:24,620 --> 00:06:24,940 ‫Right. 134 00:06:26,480 --> 00:06:34,130 ‫So let's go ahead to NPM and install Xpress and we're going to install BGI. 135 00:06:34,550 --> 00:06:38,510 ‫We can install consistent dash hash. 136 00:06:39,170 --> 00:06:40,730 ‫Let's install all that stuff. 137 00:06:40,730 --> 00:06:42,980 ‫We have installed all of that stuff. 138 00:06:43,100 --> 00:06:43,360 ‫Right. 139 00:06:43,670 --> 00:06:47,570 ‫We're going to also need crypto, but we'll use it when we really need it. 140 00:06:47,660 --> 00:06:48,860 ‫OK, so a jawdat. 141 00:06:49,280 --> 00:06:50,060 ‫Yeah, you go. 142 00:06:50,060 --> 00:06:53,480 ‫There is a Intellisense edge ordered at OK. 143 00:06:53,630 --> 00:06:54,760 ‫And what are we adding here? 144 00:06:54,950 --> 00:06:57,250 ‫We're adding essentially these buppies. 145 00:06:59,450 --> 00:07:05,720 ‫We have three nodes to be consistently hash and and so easy to use. 146 00:07:05,880 --> 00:07:10,910 ‫So once we add all that stuff, here's the thing right for now. 147 00:07:12,350 --> 00:07:20,000 ‫I'm going to do a post, right, and if you give me the you are all right, I'm going to hash that your 148 00:07:20,000 --> 00:07:23,030 ‫URL and then get a result out of it. 149 00:07:23,040 --> 00:07:23,380 ‫Right. 150 00:07:23,840 --> 00:07:27,140 ‫And then based on that result, take the first five. 151 00:07:27,140 --> 00:07:27,460 ‫Correct. 152 00:07:27,470 --> 00:07:30,290 ‫And that becomes my essentially my code. 153 00:07:30,290 --> 00:07:30,770 ‫Right. 154 00:07:30,800 --> 00:07:35,650 ‫So let's go go ahead and actually do and still might it might as well just do a crypto as well. 155 00:07:35,940 --> 00:07:36,280 ‫Right. 156 00:07:37,880 --> 00:07:38,210 ‫Come on. 157 00:07:38,450 --> 00:07:42,110 ‫Crypto will require crypto. 158 00:07:43,280 --> 00:07:43,700 ‫All right. 159 00:07:43,850 --> 00:07:47,220 ‫We're going to use crypto to do the hashing guys that we talked about. 160 00:07:47,240 --> 00:07:54,110 ‫So what we want to do essentially is take that big URL so the oil could be, I don't know, developed 161 00:07:54,430 --> 00:07:57,980 ‫Wikipedia, dot com slash, sharding, like something like that. 162 00:07:57,980 --> 00:07:58,200 ‫Right. 163 00:07:58,370 --> 00:08:04,060 ‫And I want to take that string and make it into a beautiful hash base64. 164 00:08:04,070 --> 00:08:04,940 ‫So how do we do that? 165 00:08:05,570 --> 00:08:09,260 ‫So crypto dot, I think could create hash. 166 00:08:09,260 --> 00:08:09,660 ‫Right. 167 00:08:09,860 --> 00:08:16,100 ‫And then you have to specify the functions called QA Qaa 256, because that's what the hash I'm interested 168 00:08:16,100 --> 00:08:16,340 ‫in. 169 00:08:16,550 --> 00:08:20,540 ‫And you want to update that string of data you have. 170 00:08:20,720 --> 00:08:26,530 ‫So generate the hash and then and then you want to convert it to base64, which is called the I think 171 00:08:26,630 --> 00:08:27,620 ‫digest. 172 00:08:27,950 --> 00:08:28,400 ‫Right. 173 00:08:28,400 --> 00:08:29,960 ‫And then called base sixty four. 174 00:08:29,970 --> 00:08:31,310 ‫That's what do you do with that. 175 00:08:31,310 --> 00:08:33,800 ‫Gives you a beautiful hash guys. 176 00:08:34,320 --> 00:08:40,100 ‫That's just a string of hash and that hash is a little bit long. 177 00:08:40,100 --> 00:08:43,340 ‫So let's go ahead and actually run this thing guys so you can see. 178 00:08:43,340 --> 00:08:43,910 ‫So let's go ahead. 179 00:08:43,910 --> 00:08:47,090 ‫And just this response does send back. 180 00:08:47,510 --> 00:08:51,050 ‫I don't know, let's just send back the same information. 181 00:08:51,050 --> 00:08:55,490 ‫So the hash we got and so far we don't have any other information. 182 00:08:55,490 --> 00:08:55,790 ‫Right. 183 00:08:56,030 --> 00:08:56,600 ‫That's it. 184 00:08:56,610 --> 00:08:59,720 ‫So let's just go ahead and run and make sure everything is running right. 185 00:08:59,990 --> 00:09:01,970 ‫So app we have the app get. 186 00:09:01,970 --> 00:09:02,900 ‫We forgot to listen. 187 00:09:02,900 --> 00:09:06,860 ‫Let's go app dot listen at eighty one. 188 00:09:07,310 --> 00:09:07,700 ‫Right. 189 00:09:08,400 --> 00:09:09,580 ‫I want to listen to Paul. 190 00:09:09,590 --> 00:09:10,430 ‫Eighty eighty one. 191 00:09:10,670 --> 00:09:11,690 ‫That is just a number. 192 00:09:11,690 --> 00:09:21,110 ‫So let's just do it number and then do console total listing to eighty, eighty one. 193 00:09:21,300 --> 00:09:21,650 ‫All right. 194 00:09:22,190 --> 00:09:27,170 ‫So let's just go ahead and debug, make sure we don't have any errors then we're going to get an error 195 00:09:27,170 --> 00:09:28,670 ‫because we didn't install crypto. 196 00:09:28,850 --> 00:09:29,300 ‫Right. 197 00:09:29,720 --> 00:09:30,680 ‫We didn't install crypto. 198 00:09:30,680 --> 00:09:36,080 ‫Did we go going to install crypto test in case npm install crypto. 199 00:09:37,570 --> 00:09:38,560 ‫That's right, and again. 200 00:09:40,000 --> 00:09:47,100 ‫And we're listening to Port Eighty-One, so we want to do a post request to this puppy, right? 201 00:09:47,230 --> 00:09:48,440 ‫Let's see what will happen now. 202 00:09:49,180 --> 00:09:49,480 ‫OK. 203 00:09:49,750 --> 00:09:51,090 ‫Remember, guys, what we're going to do with it. 204 00:09:51,100 --> 00:09:52,510 ‫Give it give me a call. 205 00:09:52,780 --> 00:09:57,090 ‫And Fumero, I'm going to hash that thing and get a big hash string. 206 00:09:57,190 --> 00:10:00,370 ‫I'm going to take only the five characters again. 207 00:10:00,370 --> 00:10:06,250 ‫Guys, this is not the perfect implementation of your URL shortener that are way better guys than me 208 00:10:06,460 --> 00:10:07,930 ‫doing an actual design. 209 00:10:07,930 --> 00:10:14,830 ‫Thought to our one hour video just how to build a proper hash function and to do your elshaug. 210 00:10:14,830 --> 00:10:16,900 ‫And this is just to give you an idea of sharding. 211 00:10:16,900 --> 00:10:17,220 ‫Right. 212 00:10:17,860 --> 00:10:18,220 ‫All right. 213 00:10:18,370 --> 00:10:19,930 ‫So let's go to the browser. 214 00:10:20,080 --> 00:10:20,740 ‫All right, guys. 215 00:10:20,740 --> 00:10:24,250 ‫So we go to our favorite console, right? 216 00:10:24,290 --> 00:10:30,270 ‫I'm going to use the beautiful Fitch API and just do old school way. 217 00:10:30,280 --> 00:10:32,590 ‫It's eighty, eighty one. 218 00:10:32,890 --> 00:10:40,570 ‫And I am actually the Oros HGP is Wikipedia, dot coms, sharding, whatever. 219 00:10:41,580 --> 00:10:43,270 ‫And then dot. 220 00:10:43,780 --> 00:10:45,220 ‫Yeah, we're doing a method. 221 00:10:45,370 --> 00:10:45,820 ‫Right. 222 00:10:46,300 --> 00:10:50,980 ‫The method is post and I think that's all we need. 223 00:10:51,160 --> 00:10:51,640 ‫Right. 224 00:10:52,550 --> 00:10:56,680 ‫Dot, then I'm expecting Jason back. 225 00:10:57,760 --> 00:11:00,260 ‫Give me Jason baby and console that log. 226 00:11:01,660 --> 00:11:03,670 ‫We made a request immediately. 227 00:11:03,670 --> 00:11:05,470 ‫We did the breakpoint. 228 00:11:05,800 --> 00:11:06,880 ‫We did the sharding. 229 00:11:06,880 --> 00:11:11,140 ‫We get the URL and then hash the stuff and we get this beautiful string. 230 00:11:11,170 --> 00:11:11,680 ‫Look at that. 231 00:11:12,190 --> 00:11:12,880 ‫That's trying. 232 00:11:12,880 --> 00:11:15,540 ‫I'm only interested in the first five characters, right. 233 00:11:15,790 --> 00:11:18,610 ‫We're going to take the five characters and shove into the database. 234 00:11:18,940 --> 00:11:19,300 ‫Right. 235 00:11:19,300 --> 00:11:22,180 ‫As a moral code or YOLO idea or whatever we called it. 236 00:11:22,450 --> 00:11:28,900 ‫And then that hash will determine where are we going to hit, which server is going to hit. 237 00:11:29,020 --> 00:11:30,220 ‫We're going to talk about that now. 238 00:11:30,850 --> 00:11:36,370 ‫So we're going to do that research and we're going to obviously get what we're getting, getting an 239 00:11:36,370 --> 00:11:36,760 ‫error. 240 00:11:36,760 --> 00:11:39,880 ‫For some reason, axes differ from origin. 241 00:11:40,480 --> 00:11:42,480 ‫We're not delivering the original DA. 242 00:11:42,610 --> 00:11:43,060 ‫All right. 243 00:11:43,060 --> 00:11:43,600 ‫Sure. 244 00:11:43,660 --> 00:11:44,980 ‫Let's just do a localhost. 245 00:11:44,980 --> 00:11:47,800 ‫Eighty, eighty one happier now, OK? 246 00:11:47,830 --> 00:11:49,750 ‫Or in the same location. 247 00:11:49,750 --> 00:11:50,560 ‫You're happy now? 248 00:11:51,220 --> 00:11:52,030 ‫You happy now? 249 00:11:52,030 --> 00:11:52,900 ‫I think you're happy. 250 00:11:53,140 --> 00:11:54,280 ‫I think you're happy. 251 00:11:54,640 --> 00:11:55,930 ‫I think you're happy. 252 00:11:56,230 --> 00:11:56,620 ‫All right. 253 00:11:56,620 --> 00:11:57,760 ‫Good, good, good. 254 00:11:58,000 --> 00:11:58,360 ‫All right. 255 00:11:58,690 --> 00:11:59,580 ‫So it's just like this. 256 00:11:59,620 --> 00:12:00,760 ‫This is a course thing. 257 00:12:00,760 --> 00:12:02,000 ‫We talked about my daughter. 258 00:12:02,020 --> 00:12:03,600 ‫We talk about a lot of stuff in this channel. 259 00:12:03,620 --> 00:12:05,230 ‫Guys, how are you still here? 260 00:12:05,620 --> 00:12:07,450 ‫There's so much stuff, right? 261 00:12:07,870 --> 00:12:09,520 ‫So there's a lot of tech. 262 00:12:09,520 --> 00:12:09,910 ‫Right. 263 00:12:09,910 --> 00:12:16,120 ‫And just exploring all this stuff becomes you slightly become a soft bed ourselves and enjoy as you 264 00:12:16,120 --> 00:12:19,480 ‫hit these things and start understanding your course. 265 00:12:19,840 --> 00:12:21,540 ‫Beautiful core stuff, fun. 266 00:12:21,730 --> 00:12:27,940 ‫I could have had something in the server that allows other people to access this, but I don't I just 267 00:12:28,150 --> 00:12:28,990 ‫don't feel like it. 268 00:12:29,380 --> 00:12:29,620 ‫All right. 269 00:12:29,620 --> 00:12:30,640 ‫So we have the hash back. 270 00:12:30,670 --> 00:12:31,890 ‫This is no I to go, though. 271 00:12:31,900 --> 00:12:33,130 ‫I want you to code. 272 00:12:33,280 --> 00:12:37,300 ‫What is your code, guys, that your code is essentially you are. 273 00:12:37,780 --> 00:12:43,600 ‫I'd equal hash substory OMG 025. 274 00:12:43,690 --> 00:12:46,810 ‫That's why I'm just in the first five five characters. 275 00:12:47,470 --> 00:12:49,300 ‫Not sure computer science stuff. 276 00:12:49,300 --> 00:12:52,390 ‫Is this going to give me five characters or six. 277 00:12:52,490 --> 00:12:52,770 ‫Right. 278 00:12:53,470 --> 00:12:54,520 ‫This struggle. 279 00:12:54,520 --> 00:12:57,250 ‫Man I always struggle with these. 280 00:12:57,550 --> 00:13:04,660 ‫That's and you would think five, fifteen years experience in computer science is still get this wrong 281 00:13:04,660 --> 00:13:09,400 ‫man because every implementation good that sometimes like the strings get it or start from one side 282 00:13:09,560 --> 00:13:10,210 ‫from zero. 283 00:13:10,570 --> 00:13:12,580 ‫Everyone implements their own stuff man. 284 00:13:13,240 --> 00:13:13,510 ‫Right. 285 00:13:13,540 --> 00:13:15,610 ‫So let's just do hash again. 286 00:13:16,180 --> 00:13:16,720 ‫What do we do. 287 00:13:16,720 --> 00:13:17,410 ‫We get it right. 288 00:13:17,830 --> 00:13:18,720 ‫Do we get it right. 289 00:13:18,730 --> 00:13:19,210 ‫Yes. 290 00:13:19,210 --> 00:13:20,530 ‫Looks like five characters to me. 291 00:13:20,530 --> 00:13:20,840 ‫Right. 292 00:13:21,040 --> 00:13:21,700 ‫Zero. 293 00:13:23,320 --> 00:13:25,180 ‫One, two, three, four or five. 294 00:13:25,200 --> 00:13:28,980 ‫All right, so you would think that is going to give you six, correct? 295 00:13:29,010 --> 00:13:31,980 ‫Because zero to five is actually never mind. 296 00:13:32,370 --> 00:13:32,630 ‫All right. 297 00:13:32,640 --> 00:13:34,390 ‫So now we get that. 298 00:13:34,410 --> 00:13:35,890 ‫There you are, guys. 299 00:13:35,940 --> 00:13:36,410 ‫Look at that. 300 00:13:36,870 --> 00:13:37,500 ‫Give you that. 301 00:13:37,590 --> 00:13:40,230 ‫And if I do it again, let's just remove the brake lines. 302 00:13:40,230 --> 00:13:42,300 ‫Just getting annoying now at this point. 303 00:13:43,740 --> 00:13:47,040 ‫Getting annoying, getting annoyed, remove it. 304 00:13:47,850 --> 00:13:48,210 ‫Right. 305 00:13:48,480 --> 00:13:51,210 ‫And every time we get that, we're going to get the same key. 306 00:13:51,240 --> 00:13:51,550 ‫Right. 307 00:13:51,570 --> 00:13:55,580 ‫But let's say change that to something else and we get a completely different key. 308 00:13:55,620 --> 00:13:55,870 ‫Right. 309 00:13:56,440 --> 00:13:57,540 ‫That's not what we want. 310 00:13:57,550 --> 00:13:58,600 ‫We have the key. 311 00:13:58,620 --> 00:14:00,840 ‫Now, I can write to the debates were ready almost. 312 00:14:00,840 --> 00:14:01,660 ‫We're almost ready. 313 00:14:01,710 --> 00:14:03,350 ‫It's almost almost ready. 314 00:14:03,600 --> 00:14:05,850 ‫Let's just throw in there you are actually earlier. 315 00:14:05,850 --> 00:14:06,790 ‫How about that game? 316 00:14:07,440 --> 00:14:08,720 ‫Just throwing a real shot. 317 00:14:09,000 --> 00:14:13,140 ‫And then I'm going to throw in the server because I don't know which server I'm going to connect to. 318 00:14:15,030 --> 00:14:16,140 ‫That's the tricky part, right? 319 00:14:16,510 --> 00:14:16,810 ‫Right. 320 00:14:17,190 --> 00:14:19,200 ‫So how do I know which server to connect to? 321 00:14:19,830 --> 00:14:20,580 ‫Very easy. 322 00:14:21,120 --> 00:14:23,370 ‫E back to the consistent hashing. 323 00:14:23,370 --> 00:14:23,690 ‫Right. 324 00:14:23,970 --> 00:14:25,310 ‫Which are the hash rank. 325 00:14:26,160 --> 00:14:28,500 ‫Remember we added three notes to the hash rank. 326 00:14:28,650 --> 00:14:29,010 ‫Right. 327 00:14:30,020 --> 00:14:39,460 ‫All we need to do is ask the node, hey, hash rank, I have this input, which is called your ID, 328 00:14:40,790 --> 00:14:44,080 ‫give me one of the three nodes and it will do its magic. 329 00:14:44,210 --> 00:14:49,790 ‫It will I do a module, whatever the implementation is, and it's going to give you a server. 330 00:14:51,080 --> 00:14:52,370 ‫That's the beauty of this thing. 331 00:14:53,130 --> 00:14:53,810 ‫Let's do it. 332 00:14:53,820 --> 00:14:55,490 ‫So let's see what what server do we get. 333 00:14:57,560 --> 00:15:06,170 ‫Why do this let's clean this up and then do we look at that we got four sharding when we got silver, 334 00:15:06,170 --> 00:15:09,230 ‫five, four, three, two, and we'll Diski, right? 335 00:15:09,650 --> 00:15:10,250 ‫That's funny. 336 00:15:10,250 --> 00:15:11,380 ‫It's actually says key. 337 00:15:11,390 --> 00:15:12,200 ‫Oh, my God. 338 00:15:12,530 --> 00:15:14,300 ‫That's completely a coincidence. 339 00:15:14,300 --> 00:15:17,420 ‫Let's say sharding two, we still hang in the same server. 340 00:15:17,420 --> 00:15:20,290 ‫Sharding three, we go. 341 00:15:20,300 --> 00:15:22,190 ‫We had another server, five, four, three, four. 342 00:15:22,310 --> 00:15:26,300 ‫So completely almost random write of a random. 343 00:15:27,700 --> 00:15:33,340 ‫Know, I want to hit, please give me the server three three, we didn't hit that server yet. 344 00:15:34,840 --> 00:15:36,690 ‫Dot Beatch behind. 345 00:15:37,450 --> 00:15:38,410 ‫Five, four, three. 346 00:15:38,410 --> 00:15:41,120 ‫To admit I want five, four, three, three. 347 00:15:41,380 --> 00:15:42,910 ‫Can you give me five, four, three, three. 348 00:15:44,240 --> 00:15:46,940 ‫A random dude that gives me a five, four, three, two. 349 00:15:47,020 --> 00:15:48,400 ‫OK, that's what I'm talking about. 350 00:15:48,540 --> 00:15:53,620 ‫Just as you start running, this will almost balance that stuff in a consistent manner. 351 00:15:53,650 --> 00:15:58,960 ‫And every time you do the same exact way, you're going to hit the same exact server. 352 00:15:59,160 --> 00:16:02,890 ‫OK, we have all the pieces, guys, all the pieces here. 353 00:16:03,130 --> 00:16:05,800 ‫So how about we actually write this stuff to the database? 354 00:16:05,800 --> 00:16:06,100 ‫Right. 355 00:16:06,670 --> 00:16:07,300 ‫Let's write it. 356 00:16:07,450 --> 00:16:08,870 ‫How do you write stuff to the database? 357 00:16:09,070 --> 00:16:09,850 ‫Very simple. 358 00:16:09,850 --> 00:16:11,470 ‫We we need to get the client right. 359 00:16:11,660 --> 00:16:13,270 ‫The clients are in this bunch. 360 00:16:13,270 --> 00:16:13,470 ‫Right. 361 00:16:13,480 --> 00:16:14,950 ‫Clients sub. 362 00:16:15,100 --> 00:16:17,140 ‫Guess what, what's the sub here. 363 00:16:18,040 --> 00:16:19,180 ‫I want this up server. 364 00:16:19,720 --> 00:16:20,050 ‫Right. 365 00:16:20,240 --> 00:16:21,370 ‫Because this is the key. 366 00:16:21,370 --> 00:16:21,640 ‫Right. 367 00:16:21,910 --> 00:16:28,750 ‫Because now I have the server, which is a string of port that will give me back the object and the 368 00:16:28,750 --> 00:16:29,410 ‫object. 369 00:16:29,410 --> 00:16:33,460 ‫When I get that thing, I want to query that. 370 00:16:33,460 --> 00:16:33,800 ‫Right. 371 00:16:33,910 --> 00:16:35,410 ‫Why is it not showing me Intellisense? 372 00:16:35,620 --> 00:16:38,500 ‫I think it's unaware that is actually an object. 373 00:16:38,530 --> 00:16:40,960 ‫Well, I'm pretty sure that should work. 374 00:16:42,140 --> 00:16:43,910 ‫So select start that idea. 375 00:16:43,940 --> 00:16:47,170 ‫Don't ever do a star in your database lets you know what you're doing. 376 00:16:47,770 --> 00:16:48,070 ‫Right. 377 00:16:48,070 --> 00:16:49,690 ‫So it's called your underscore table. 378 00:16:50,430 --> 00:16:52,300 ‫I'd like to make things big. 379 00:16:52,330 --> 00:16:52,960 ‫That's what she said. 380 00:16:53,230 --> 00:16:56,590 ‫Select star from the oil and gas go table. 381 00:16:56,860 --> 00:16:57,070 ‫Yeah. 382 00:16:57,070 --> 00:16:59,600 ‫I don't know what sequel's all of that has to be caps lock. 383 00:16:59,830 --> 00:17:00,150 ‫All right. 384 00:17:00,160 --> 00:17:07,610 ‫It's just something we learned back when I do when I used to do Oracle stuff back in 2005. 385 00:17:07,610 --> 00:17:08,470 ‫Thousand four actually. 386 00:17:08,520 --> 00:17:08,890 ‫Yeah. 387 00:17:09,610 --> 00:17:10,240 ‫First job. 388 00:17:10,550 --> 00:17:10,880 ‫All right. 389 00:17:10,900 --> 00:17:14,710 ‫So where are we to where what? 390 00:17:15,640 --> 00:17:24,930 ‫Why are we selecting that's not what we're inserting insert into your RL table, right, inserting what 391 00:17:24,960 --> 00:17:32,340 ‫ID is going to be automatically generated the oral and the oral I.D. and then we do the values and then 392 00:17:32,850 --> 00:17:36,630 ‫the fancy stuff, one and two. 393 00:17:37,050 --> 00:17:44,020 ‫And the one is equal oral and the other one is the URL already. 394 00:17:44,340 --> 00:17:44,970 ‫OK. 395 00:17:46,510 --> 00:17:47,970 ‫Sounds good, right? 396 00:17:48,850 --> 00:17:53,400 ‫Let's look ahead and talk to me right now, I will insert, but you have to await that, right? 397 00:17:53,500 --> 00:17:57,870 ‫And since we're awaiting that function that we're in, better be async, right? 398 00:17:58,230 --> 00:17:59,000 ‫That's OK. 399 00:17:59,590 --> 00:18:03,010 ‫Now, we have to send that push always to recording. 400 00:18:03,140 --> 00:18:03,390 ‫Good. 401 00:18:03,830 --> 00:18:03,930 ‫Right. 402 00:18:03,990 --> 00:18:07,990 ‫So now we're sending that back and then we are sure that, hey, we got it. 403 00:18:08,080 --> 00:18:08,340 ‫OK. 404 00:18:08,620 --> 00:18:14,740 ‫I mean, I kind of had a try catch and be like a little bit more fancy, but yeah. 405 00:18:15,040 --> 00:18:17,530 ‫Let's just make sure that we actually made it right. 406 00:18:17,890 --> 00:18:19,240 ‫Otherwise we're going to get an error. 407 00:18:19,240 --> 00:18:21,780 ‫So let's do it, guys. 408 00:18:21,790 --> 00:18:22,420 ‫Let's do it. 409 00:18:22,510 --> 00:18:22,780 ‫Do it. 410 00:18:22,960 --> 00:18:24,730 ‫Refresh right. 411 00:18:25,330 --> 00:18:27,190 ‫And post. 412 00:18:27,940 --> 00:18:29,860 ‫Wow, that's bull. 413 00:18:29,880 --> 00:18:30,610 ‫Did that work. 414 00:18:30,820 --> 00:18:31,520 ‫I'll buy that. 415 00:18:31,540 --> 00:18:32,500 ‫What server is that. 416 00:18:32,500 --> 00:18:33,540 ‫Five, four, three, three. 417 00:18:33,550 --> 00:18:34,510 ‫So how do we go. 418 00:18:34,540 --> 00:18:36,520 ‫Which is five, four, five, four, three, three. 419 00:18:37,050 --> 00:18:39,820 ‫I -- I should have just put the right number here. 420 00:18:39,820 --> 00:18:42,190 ‫I don't know which was four four three three. 421 00:18:42,460 --> 00:18:43,510 ‫I think that's the one. 422 00:18:43,530 --> 00:18:45,640 ‫OK, charge to his four for safety. 423 00:18:46,120 --> 00:18:49,750 ‫OK, public and we got tables. 424 00:18:51,010 --> 00:18:52,390 ‫Do we have a roll guys. 425 00:18:52,540 --> 00:18:53,590 ‫Do we have a row. 426 00:18:54,220 --> 00:18:54,940 ‫Do we ever. 427 00:18:54,940 --> 00:18:57,130 ‫Oh yeah. 428 00:18:57,210 --> 00:18:58,480 ‫Sorry. 429 00:18:58,490 --> 00:18:59,740 ‫What the heck was that. 430 00:18:59,740 --> 00:19:01,030 ‫Printing PDF. 431 00:19:01,030 --> 00:19:02,710 ‫Why Jesus. 432 00:19:02,710 --> 00:19:05,320 ‫OK, Celle, look at that. 433 00:19:05,830 --> 00:19:07,420 ‫Beautiful stuff guys. 434 00:19:07,810 --> 00:19:08,680 ‫Wow. 435 00:19:08,710 --> 00:19:09,580 ‫Well how about we do it. 436 00:19:09,580 --> 00:19:10,120 ‫Another one. 437 00:19:10,120 --> 00:19:11,680 ‫OK, another one. 438 00:19:12,280 --> 00:19:14,560 ‫Did you got it right. 439 00:19:15,130 --> 00:19:16,170 ‫And it's same server. 440 00:19:16,180 --> 00:19:17,050 ‫OK, sure. 441 00:19:17,050 --> 00:19:18,310 ‫It's easier to me. 442 00:19:18,730 --> 00:19:19,070 ‫Right. 443 00:19:19,510 --> 00:19:20,980 ‫Would like that. 444 00:19:21,010 --> 00:19:23,350 ‫I'm not the one and that's the key. 445 00:19:24,360 --> 00:19:30,690 ‫Right, let's do it on Google dot com doesn't have to be Wikipedia, right? 446 00:19:32,480 --> 00:19:32,960 ‫Ali? 447 00:19:35,170 --> 00:19:43,930 ‫Refresh, which that we had another server, let's go to that server, five short three guys, I'm going 448 00:19:43,930 --> 00:19:48,280 ‫to I'm going to reference that could be a blow so you don't have to, like, pause and do all that stuff. 449 00:19:48,640 --> 00:19:48,910 ‫Right. 450 00:19:49,450 --> 00:19:50,380 ‫Goofy stuff. 451 00:19:50,380 --> 00:19:54,170 ‫You just you just go to the GitHub page. 452 00:19:54,190 --> 00:19:55,780 ‫Look at that, guys. 453 00:19:55,970 --> 00:20:00,880 ‫So we're consistently hashing the F out of this stuff, man. 454 00:20:01,120 --> 00:20:02,620 ‫Consistent, Beebs. 455 00:20:02,920 --> 00:20:05,480 ‫That's what we're talking about consistently. 456 00:20:05,750 --> 00:20:06,260 ‫All right. 457 00:20:06,670 --> 00:20:07,250 ‫About that. 458 00:20:07,270 --> 00:20:10,780 ‫That's just throwing some of that Yarl's equal. 459 00:20:11,750 --> 00:20:17,000 ‫How do I do you oil's right, let's just do it 460 00:20:20,030 --> 00:20:33,380 ‫I less than 100 or less, and then it is like you URL's to push this Google dot com slash in India because 461 00:20:33,380 --> 00:20:33,880 ‫why not? 462 00:20:33,890 --> 00:20:34,880 ‫Let's go there. 463 00:20:36,800 --> 00:20:46,750 ‫I search for Q equal test that I have to do the text. 464 00:20:47,240 --> 00:20:48,230 ‫Can you read guys. 465 00:20:48,440 --> 00:20:49,600 ‫You can read this book. 466 00:20:49,610 --> 00:20:50,780 ‫I'm going to zoom in a little bit. 467 00:20:51,170 --> 00:20:51,290 ‫Right. 468 00:20:51,350 --> 00:20:52,130 ‫Sorry about that. 469 00:20:52,640 --> 00:20:56,240 ‫So we added how many URLs we have a lot of your old guys. 470 00:20:56,450 --> 00:20:57,780 ‫So many URLs. 471 00:20:57,800 --> 00:20:58,490 ‫Oh my God. 472 00:20:58,500 --> 00:21:05,930 ‫Let's go and let's do it right this time, guys, for each you you doing it on me. 473 00:21:06,080 --> 00:21:08,330 ‫I like it when you do No. 474 00:21:08,470 --> 00:21:08,940 ‫One. 475 00:21:12,150 --> 00:21:17,950 ‫You believe God is a woman, right? 476 00:21:19,130 --> 00:21:22,550 ‫Well, all right, I think that's right. 477 00:21:23,290 --> 00:21:26,810 ‫Right, though, did I get it right? 478 00:21:27,230 --> 00:21:31,110 ‫I really doubt it, but sure, let's do it. 479 00:21:31,850 --> 00:21:33,300 ‫Oh, Mama. 480 00:21:33,300 --> 00:21:33,650 ‫I see. 481 00:21:34,250 --> 00:21:34,780 ‫Look at that. 482 00:21:35,270 --> 00:21:37,190 ‫Look at all that stuff. 483 00:21:37,200 --> 00:21:39,140 ‫OK, so we had like a bunch of servers. 484 00:21:39,140 --> 00:21:44,830 ‫We had five, four, three, three, five for all that jazz and Shailesh. 485 00:21:45,590 --> 00:21:46,730 ‫Oh, my God. 486 00:21:47,420 --> 00:21:49,530 ‫Look at all beautiful stuff, man. 487 00:21:50,150 --> 00:21:50,780 ‫All right. 488 00:21:51,110 --> 00:21:52,490 ‫We know the stuff is working. 489 00:21:52,490 --> 00:21:55,330 ‫Guys were distributed consistently. 490 00:21:55,970 --> 00:21:56,500 ‫All right. 491 00:21:57,920 --> 00:21:58,610 ‫How about that?