1 00:00:00,210 --> 00:00:01,780 ‫What is going on, guys? 2 00:00:01,800 --> 00:00:04,790 ‫My name is Hussein, and this is the third episode of Suffragette. 3 00:00:04,980 --> 00:00:07,520 ‫Today's topic is distributor transaction. 4 00:00:07,530 --> 00:00:12,270 ‫Some of you ask me why this what is this thing distributed? 5 00:00:12,720 --> 00:00:17,880 ‫And to be honest, when I heard that when I heard that question, what is distributing a distribution 6 00:00:17,880 --> 00:00:18,490 ‫transaction? 7 00:00:18,510 --> 00:00:20,010 ‫What is the saga thing? 8 00:00:20,010 --> 00:00:21,600 ‫And I didn't know anything about it. 9 00:00:22,320 --> 00:00:29,160 ‫I read some articles talking about distribution transaction with within the context of Google Atomic 10 00:00:29,160 --> 00:00:33,870 ‫Clock, and I know I exist and this is then, but I didn't know why. 11 00:00:34,440 --> 00:00:40,550 ‫In the vernacular, why does this technology exist and why do we need distribution transaction? 12 00:00:40,560 --> 00:00:41,610 ‫What other solutions? 13 00:00:41,630 --> 00:00:44,370 ‫So I spent some time doing some research. 14 00:00:44,940 --> 00:00:51,640 ‫I'm going to reference all the videos I wash all the articles I read to kind of summarize this for you. 15 00:00:51,660 --> 00:00:55,520 ‫So and this video, I'm going to talk about distribution transactions. 16 00:00:55,830 --> 00:00:57,030 ‫Why does it exist? 17 00:00:57,030 --> 00:01:02,670 ‫Because I like all of us to start that any technology in software engineering exist for a reason. 18 00:01:02,940 --> 00:01:05,610 ‫And if it exists, it solves the problem. 19 00:01:05,610 --> 00:01:06,840 ‫What problems does solve? 20 00:01:06,960 --> 00:01:07,290 ‫Right. 21 00:01:07,620 --> 00:01:08,880 ‫And maybe. 22 00:01:09,920 --> 00:01:15,840 ‫That problem could happen to certain sector of engineers, not everybody. 23 00:01:16,370 --> 00:01:18,080 ‫That's why I'd like to address this problem. 24 00:01:18,130 --> 00:01:20,480 ‫Like, do you really need distributer transaction? 25 00:01:20,510 --> 00:01:22,220 ‫Well, what's your problem? 26 00:01:22,220 --> 00:01:23,900 ‫Like, that's that's why I'd like to do it. 27 00:01:24,530 --> 00:01:31,220 ‫And then I'm going to talk about the different solutions to distribution transactions, because there's 28 00:01:31,460 --> 00:01:32,990 ‫that's the beauty of social engineering. 29 00:01:33,300 --> 00:01:36,020 ‫There is no one way to solve a problem. 30 00:01:36,050 --> 00:01:37,400 ‫There are many, many, many ways. 31 00:01:37,870 --> 00:01:43,180 ‫That's what makes us really, really a creative endeavor field. 32 00:01:43,190 --> 00:01:47,520 ‫If you're a software engineer, you're and you come up with solutions, you're a create. 33 00:01:47,570 --> 00:01:49,580 ‫You're like an artist, man. 34 00:01:49,730 --> 00:01:55,490 ‫Just, yeah, you're an artist because coming up with creative solutions to solve our engineering problems, 35 00:01:55,490 --> 00:01:58,490 ‫it's it's an art, whether you like it or not. 36 00:01:58,620 --> 00:02:02,750 ‫So I respect anyone whether the solution is bad or good. 37 00:02:03,290 --> 00:02:04,580 ‫It's an art by itself. 38 00:02:04,610 --> 00:02:10,550 ‫You don't look at a painting and say, oh, that's that's not that's that's not the right painting or 39 00:02:11,090 --> 00:02:12,440 ‫that's a wrong painting. 40 00:02:12,440 --> 00:02:13,600 ‫You know, you can say that, right? 41 00:02:13,700 --> 00:02:15,290 ‫It's just it's an expression. 42 00:02:15,290 --> 00:02:15,980 ‫And I like it. 43 00:02:17,090 --> 00:02:18,710 ‫That being said, let's just jump into it. 44 00:02:19,250 --> 00:02:19,520 ‫All right. 45 00:02:19,520 --> 00:02:23,780 ‫So why does distribution distributor transaction exist? 46 00:02:23,780 --> 00:02:24,170 ‫Right. 47 00:02:24,410 --> 00:02:25,730 ‫So what is this thing? 48 00:02:26,930 --> 00:02:32,750 ‫Before we jump to distribute the transaction, let's briefly take some time to talk about transactions 49 00:02:32,750 --> 00:02:33,290 ‫in general. 50 00:02:33,290 --> 00:02:37,070 ‫I made a video about transactions and acid and all that stuff. 51 00:02:37,070 --> 00:02:38,210 ‫I'm going to freeze it right here. 52 00:02:38,480 --> 00:02:39,230 ‫Go check it out. 53 00:02:39,260 --> 00:02:41,690 ‫I really recommend you understand these basics. 54 00:02:42,080 --> 00:02:46,520 ‫I think every software engineer need to understand what acid is a tomasetti, consistency, isolation, 55 00:02:47,210 --> 00:02:47,810 ‫durability. 56 00:02:47,810 --> 00:02:52,820 ‫So that's why I made a full course, almost video one hour talking about these things. 57 00:02:52,820 --> 00:02:57,100 ‫It's at a very critical topic to discuss as a versing. 58 00:02:57,110 --> 00:02:57,380 ‫Right. 59 00:02:58,390 --> 00:02:59,950 ‫A transaction is. 60 00:03:00,920 --> 00:03:06,560 ‫And I'm going to take the example that I'm seeing all the time is this order payment kind of thing. 61 00:03:06,570 --> 00:03:11,250 ‫Let's say you're you're building Amazon or building some application that does ordering and payment, 62 00:03:11,280 --> 00:03:11,550 ‫OK? 63 00:03:12,020 --> 00:03:14,330 ‫And it's a Web application. 64 00:03:14,330 --> 00:03:21,860 ‫So we have one Web server or WAP framework, maybe a Norges application or a B application that does 65 00:03:21,860 --> 00:03:22,930 ‫the whole thing for you. 66 00:03:22,940 --> 00:03:23,270 ‫Right. 67 00:03:23,300 --> 00:03:32,960 ‫You submit a request, arrest maybe or or graft you up and you say, hey, I am I want to I have these 68 00:03:32,960 --> 00:03:33,710 ‫in my cart. 69 00:03:33,710 --> 00:03:36,920 ‫I want to buy the stuff. 70 00:03:36,920 --> 00:03:37,280 ‫Right. 71 00:03:37,730 --> 00:03:39,890 ‫So what is by this stuff mean? 72 00:03:39,930 --> 00:03:49,610 ‫It means that submit an order, charge my credit card and update the order and email me with the order 73 00:03:49,610 --> 00:03:53,540 ‫details and when is going to be shipped and all that jazz. 74 00:03:54,560 --> 00:03:54,910 ‫All right. 75 00:03:55,010 --> 00:03:56,040 ‫How do we do it today? 76 00:03:56,420 --> 00:03:57,410 ‫Very simple. 77 00:03:57,650 --> 00:03:58,490 ‫Very elegant. 78 00:03:58,500 --> 00:04:00,980 ‫We figured it out back in the 70s. 79 00:04:00,980 --> 00:04:02,870 ‫How to do this transactions right. 80 00:04:03,380 --> 00:04:04,600 ‫In an atomic manner. 81 00:04:04,730 --> 00:04:10,550 ‫That means all of these updates have to happen at the same time or none of them happen otherwise. 82 00:04:10,550 --> 00:04:13,960 ‫We lead into these inconsistent state, which aren't that OK? 83 00:04:16,170 --> 00:04:19,650 ‫Cotton gone bad, not bad for overapplication, but bad in this case. 84 00:04:20,310 --> 00:04:21,930 ‫All right, so how do we build it? 85 00:04:21,960 --> 00:04:22,380 ‫Well. 86 00:04:23,400 --> 00:04:30,030 ‫I am going to receive the request, this is something I want to buy these items, so I'm going to insert 87 00:04:30,030 --> 00:04:33,000 ‫these items and I'm going to create an order. 88 00:04:33,330 --> 00:04:36,060 ‫I'm going to create a bunch of items. 89 00:04:36,270 --> 00:04:36,630 ‫Right. 90 00:04:36,630 --> 00:04:39,420 ‫And insert these items and do the orders or there's a row. 91 00:04:39,420 --> 00:04:42,390 ‫And there was another maybe another table or other items, whatever. 92 00:04:42,690 --> 00:04:44,520 ‫And then item one item to item three. 93 00:04:44,790 --> 00:04:51,750 ‫And I'm going to update the status of them of the order saying, oh, this is initialized now and then 94 00:04:51,750 --> 00:04:57,510 ‫I'm going to go ahead and charge my the payment method. 95 00:04:58,320 --> 00:04:59,610 ‫You're using MasterCard. 96 00:04:59,620 --> 00:05:01,050 ‫OK, charge it. 97 00:05:01,320 --> 00:05:09,000 ‫If I succeed, I am going to move in and maybe estimate the delivery, say, OK, it's going to take 98 00:05:09,000 --> 00:05:16,110 ‫a week to deliver and then I'm going to update the order status to be paid because I another update 99 00:05:16,110 --> 00:05:23,730 ‫statements or the first insert and insert, maybe insert the payment method because I submitted it, 100 00:05:24,810 --> 00:05:26,850 ‫I just inserted it, not committed yet. 101 00:05:27,210 --> 00:05:34,200 ‫And then I update the order and then finally because the payment, all of these statements are now true 102 00:05:34,200 --> 00:05:36,510 ‫and correct, I'm going to commit. 103 00:05:36,900 --> 00:05:37,260 ‫Right. 104 00:05:37,350 --> 00:05:43,420 ‫And this is a whole bunch of atomic operations now. 105 00:05:43,440 --> 00:05:47,790 ‫This is one atomic operation, one transaction, OK, work, one unit of work. 106 00:05:48,510 --> 00:05:51,330 ‫Well, and that's what happened. 107 00:05:51,330 --> 00:05:53,250 ‫If the payments failed, well, the payments failed. 108 00:05:53,250 --> 00:05:56,100 ‫I want to roll back the whole thing, like the order didn't exist. 109 00:05:58,320 --> 00:06:01,090 ‫And just emailed that he was the hey failed. 110 00:06:01,130 --> 00:06:04,800 ‫I'm not going to even submit the order because your payment didn't charge a while. 111 00:06:04,980 --> 00:06:06,300 ‫Why would I create an order? 112 00:06:06,420 --> 00:06:07,490 ‫Just useless. 113 00:06:07,500 --> 00:06:07,680 ‫Right? 114 00:06:08,820 --> 00:06:10,710 ‫So that's that's a technical operation. 115 00:06:10,710 --> 00:06:10,980 ‫Right. 116 00:06:11,250 --> 00:06:13,590 ‫And you can do all of that stuff because all of this. 117 00:06:14,930 --> 00:06:20,270 ‫Work or methods or this is the same process that is running, it's either a Web server running or maybe 118 00:06:20,390 --> 00:06:26,150 ‫even a veteran, a client server back when he was a client server application, you said you have one 119 00:06:26,150 --> 00:06:28,670 ‫process running and it's doing this thing. 120 00:06:28,880 --> 00:06:35,900 ‫And the TCP connection between you and the database is one TCP connection dedicated for this transaction. 121 00:06:38,160 --> 00:06:39,760 ‫Easy peasy, right? 122 00:06:40,260 --> 00:06:49,140 ‫We out how to do that, meet micro services, micro services came in and says, no, these big applications 123 00:06:49,140 --> 00:06:54,330 ‫that does too many things are bad because they don't not scale. 124 00:06:55,050 --> 00:07:03,570 ‫Because we cannot we can't we don't have the luxury of picking up my own languages as team. 125 00:07:03,570 --> 00:07:06,540 ‫All the teams are forced to use the same programming language. 126 00:07:06,840 --> 00:07:15,410 ‫And these hip kids these days like to use JavaScript and Rust and what other languages these days go. 127 00:07:15,420 --> 00:07:17,790 ‫Yeah, everybody used to live in new languages. 128 00:07:17,790 --> 00:07:18,010 ‫Right? 129 00:07:18,030 --> 00:07:18,520 ‫So no. 130 00:07:19,080 --> 00:07:21,300 ‫So meet Microsoft says let's break things up. 131 00:07:22,080 --> 00:07:23,280 ‫We have problems with that. 132 00:07:23,290 --> 00:07:25,380 ‫Obviously, I discussed most of these problems. 133 00:07:26,650 --> 00:07:30,060 ‫The side Microsoft vs. whites good, whites bad. 134 00:07:30,840 --> 00:07:34,350 ‫But regardless, it's there it's here to stay microdevices. 135 00:07:34,350 --> 00:07:37,300 ‫It's painful, but it gives you some advantages. 136 00:07:37,320 --> 00:07:42,420 ‫So let's discuss what problems arise with Microsoft as will come back to this. 137 00:07:42,420 --> 00:07:47,610 ‫My ordering courting Ramezani kind of like system. 138 00:07:47,850 --> 00:07:51,670 ‫Well, the order code should live on its own server as well. 139 00:07:52,140 --> 00:07:56,730 ‫That's been up and OJEA servers and the spin up by order service. 140 00:07:56,730 --> 00:07:58,710 ‫And this is just for creating orders. 141 00:07:59,220 --> 00:08:02,520 ‫And the payment service is a completely different team, right? 142 00:08:02,530 --> 00:08:02,720 ‫Yeah. 143 00:08:02,730 --> 00:08:07,560 ‫Maybe you outsource to, I don't know, square or stripe or something like that. 144 00:08:07,560 --> 00:08:07,830 ‫Right. 145 00:08:07,830 --> 00:08:09,480 ‫So that's another service itself. 146 00:08:09,720 --> 00:08:14,510 ‫And then which is going to use for I you didn't see the benefits of this and then I don't know, the 147 00:08:15,420 --> 00:08:20,700 ‫the shipment is another service and and you can see now these are now not one process. 148 00:08:20,700 --> 00:08:21,830 ‫They are multiple processes. 149 00:08:21,830 --> 00:08:23,610 ‫Stop the order service. 150 00:08:23,880 --> 00:08:26,850 ‫Even if all of them talk to the same, that you still have the same problem. 151 00:08:27,060 --> 00:08:30,810 ‫But most of them now with micro services have their own flavor of a database. 152 00:08:30,990 --> 00:08:40,800 ‫So the order could use Postgres and and and the the payment could use Mongo DB and the shipment could 153 00:08:40,800 --> 00:08:41,340 ‫use. 154 00:08:42,500 --> 00:08:44,190 ‫OK, Sandra, who cares. 155 00:08:44,190 --> 00:08:44,570 ‫Right. 156 00:08:44,580 --> 00:08:48,340 ‫And good luck making one transaction between all these three databases. 157 00:08:48,360 --> 00:08:49,050 ‫It's impossible. 158 00:08:49,230 --> 00:08:49,640 ‫Right. 159 00:08:50,460 --> 00:08:55,680 ‫So yeah, even if it's one database, it's impossible to make a transaction, a single transaction that 160 00:08:55,680 --> 00:08:57,470 ‫you can roll back if something failed. 161 00:08:57,870 --> 00:08:59,880 ‫So now let's run through our scenario. 162 00:09:00,180 --> 00:09:02,160 ‫I supplement a beautiful order. 163 00:09:02,610 --> 00:09:03,870 ‫I go to the order service. 164 00:09:03,870 --> 00:09:04,170 ‫Right. 165 00:09:04,500 --> 00:09:09,660 ‫Assuming there is some sort of an ingress or reverse proxy that receives that thing and funnel and fan 166 00:09:09,660 --> 00:09:12,130 ‫out request accordingly. 167 00:09:12,190 --> 00:09:14,070 ‫That depends how it's done. 168 00:09:14,070 --> 00:09:15,240 ‫There are many ways to do it. 169 00:09:16,080 --> 00:09:23,670 ‫But I go ahead and submit that order so that orders say, OK, order created succeeded. 170 00:09:24,180 --> 00:09:26,820 ‫Go back now, submit the payment. 171 00:09:27,810 --> 00:09:29,220 ‫I'm the reverse proxy by the way. 172 00:09:29,250 --> 00:09:30,330 ‫Order succeed. 173 00:09:30,690 --> 00:09:31,830 ‫Go do the payment. 174 00:09:31,830 --> 00:09:32,400 ‫Succeed. 175 00:09:32,400 --> 00:09:32,790 ‫Good. 176 00:09:33,360 --> 00:09:33,960 ‫Come back. 177 00:09:34,440 --> 00:09:35,130 ‫Do that. 178 00:09:35,670 --> 00:09:38,010 ‫Go ahead and do the shipment succeed. 179 00:09:38,520 --> 00:09:39,390 ‫Email the customer. 180 00:09:39,570 --> 00:09:42,330 ‫So that's that's three transactions, right. 181 00:09:42,330 --> 00:09:49,250 ‫It's not one transaction but logically in the vascular it is one transaction to the user who gives the 182 00:09:49,260 --> 00:09:51,690 ‫user doesn't know what you are using and doesn't know. 183 00:09:51,810 --> 00:09:55,590 ‫He doesn't know or she doesn't know that you're using a transactional microdevices back end. 184 00:09:55,800 --> 00:09:56,670 ‫Who cares. 185 00:09:56,730 --> 00:09:57,120 ‫Right. 186 00:09:57,780 --> 00:09:58,620 ‫So you're doing that. 187 00:09:58,620 --> 00:10:00,540 ‫And what happened is the payment now fail. 188 00:10:00,580 --> 00:10:02,880 ‫All payments fail, rollback back. 189 00:10:03,360 --> 00:10:03,900 ‫Tough luck. 190 00:10:03,900 --> 00:10:09,360 ‫You can either roll back because that was a commit that order actually committed to the database. 191 00:10:09,690 --> 00:10:10,080 ‫Right. 192 00:10:11,420 --> 00:10:16,640 ‫And now you have to tell, oh, by the way, the payments failed, so, hey, order, can you just. 193 00:10:17,550 --> 00:10:19,380 ‫Rollback does not rollback. 194 00:10:19,480 --> 00:10:26,730 ‫So you have to do these ugly things that's compensating it, its it's like, oh, order, delete the 195 00:10:26,730 --> 00:10:33,240 ‫order, actually do a physical delete to go ahead and delete the order, which is kind of expensive 196 00:10:33,240 --> 00:10:36,300 ‫because now you have rows in the database that you're doing. 197 00:10:36,480 --> 00:10:38,430 ‫You're making the database do multiple work. 198 00:10:38,940 --> 00:10:42,300 ‫Obviously it's not so much, but still it's work. 199 00:10:43,120 --> 00:10:43,490 ‫Right. 200 00:10:43,830 --> 00:10:47,970 ‫And if your database actually having it's in a cemetery. 201 00:10:47,970 --> 00:10:54,270 ‫So all of these actually whereas entries that in the in your database so you will see them in your SSD 202 00:10:54,270 --> 00:10:55,090 ‫drive or wherever. 203 00:10:55,680 --> 00:10:58,190 ‫So it's expensive nevertheless. 204 00:10:58,470 --> 00:10:58,790 ‫Right. 205 00:10:59,850 --> 00:11:01,620 ‫Go back and do all the same. 206 00:11:01,650 --> 00:11:03,280 ‫So that's the problem. 207 00:11:03,660 --> 00:11:04,380 ‫That's why. 208 00:11:05,390 --> 00:11:11,380 ‫Distributed transactions was invented, my god, 11 minutes to just get to the point, right? 209 00:11:13,220 --> 00:11:14,680 ‫That's why I cannot do this stuff. 210 00:11:14,710 --> 00:11:16,140 ‫Individual stories, guys. 211 00:11:16,340 --> 00:11:17,210 ‫It's very hard. 212 00:11:17,450 --> 00:11:22,970 ‫And you guys told me that you want this content pulled from the YouTube story and actually made into 213 00:11:22,970 --> 00:11:23,300 ‫a video. 214 00:11:23,340 --> 00:11:24,140 ‫That's why I'm doing it. 215 00:11:24,860 --> 00:11:29,990 ‫Me know if this is a good idea, if you like it or not, if the content is boring or you are trying 216 00:11:29,990 --> 00:11:31,820 ‫to make it as entertaining as possible. 217 00:11:32,240 --> 00:11:37,460 ‫Software engineering is not attractive for everybody, but that's why we have this transaction. 218 00:11:37,490 --> 00:11:39,610 ‫Now let's jump into the solutions. 219 00:11:39,950 --> 00:11:43,460 ‫What can we do to fix daing this thing? 220 00:11:44,030 --> 00:11:45,350 ‫What what problems can we sell? 221 00:11:45,900 --> 00:11:48,800 ‫Well, we talked about one of them. 222 00:11:49,080 --> 00:11:52,580 ‫Let's talk about the best one, which is Google have invented. 223 00:11:52,850 --> 00:11:53,270 ‫Right. 224 00:11:53,930 --> 00:11:56,060 ‫Which is called atomic clocks. 225 00:11:56,660 --> 00:11:56,990 ‫Right. 226 00:11:57,500 --> 00:12:03,320 ‫Google decided that all of their database using they have a database called Spanner. 227 00:12:03,680 --> 00:12:10,050 ‫And all of these databases, have they they they have the same exact time. 228 00:12:10,110 --> 00:12:12,800 ‫OK, and if you make a transaction. 229 00:12:13,850 --> 00:12:20,270 ‫They know exactly what order of these transaction that happened, so they know because the time is so 230 00:12:20,270 --> 00:12:25,970 ‫accurate, they nailed the time to the nearly microsecond maybe I don't know the details about that. 231 00:12:26,990 --> 00:12:31,820 ‫And they were using atomic clock to actually synchronize all the databases so that you can actually 232 00:12:31,820 --> 00:12:36,080 ‫physically do a transaction and roll it back because you know the steps, right? 233 00:12:36,390 --> 00:12:37,170 ‫So they figured it out. 234 00:12:37,190 --> 00:12:42,380 ‫I don't know the details about that, but that's how they do distributed transactions there. 235 00:12:42,890 --> 00:12:48,110 ‫Another method, obviously not everybody has Google and nobody for the atomic clocks. 236 00:12:48,410 --> 00:12:54,080 ‫So what the other solution is, do this compensating edits. 237 00:12:54,080 --> 00:13:02,150 ‫Right, which is we talked about it created order, do a payment of the famous failed, come back and 238 00:13:02,150 --> 00:13:03,560 ‫go actually delete the order. 239 00:13:03,560 --> 00:13:07,670 ‫So just for each operation that you do, reverse it, reverse it. 240 00:13:07,770 --> 00:13:10,340 ‫You have to try to reverse a lot of work for you. 241 00:13:10,760 --> 00:13:17,330 ‫Very complicated logic to write, but it could happen, but very prone to bugs, I think. 242 00:13:18,020 --> 00:13:20,510 ‫So that's one way to do it the other way. 243 00:13:20,720 --> 00:13:27,380 ‫Instead of just doing this, having one process, do this stuff for you, which is also prone to failure, 244 00:13:27,380 --> 00:13:33,950 ‫because if this process dies, you lost your you you will be in an inconsistent state, which is the 245 00:13:33,950 --> 00:13:36,830 ‫second one, which I like a lot, the eventing model. 246 00:13:37,130 --> 00:13:38,330 ‫So the eventing model. 247 00:13:39,540 --> 00:13:48,890 ‫Coupled up with the what the what what's called with the compensating edit model SILLIAC. 248 00:13:49,790 --> 00:13:51,100 ‫Use COFCO, go in. 249 00:13:51,140 --> 00:14:00,020 ‫Q And when you publish when you create an order, the order service actually writes to that. 250 00:14:00,020 --> 00:14:03,230 ‫Q Or the public or a Kafka topic. 251 00:14:03,590 --> 00:14:05,320 ‫And by the way, I talked about cough, cough. 252 00:14:05,330 --> 00:14:06,110 ‫Check it out here. 253 00:14:07,050 --> 00:14:14,200 ‫Intellichoice Topinka says order has been created and people, people, services listen to this topic 254 00:14:14,210 --> 00:14:18,740 ‫and says, oh, look, created, it's my job as a payment service to pick up this order that I created 255 00:14:18,740 --> 00:14:19,550 ‫and start to pay it. 256 00:14:19,730 --> 00:14:25,790 ‫And if it paid it, what it does is says, OK, if it successful, it writes another topic, says payment 257 00:14:25,790 --> 00:14:27,530 ‫order paid successfully. 258 00:14:27,860 --> 00:14:32,540 ‫So the shipment service will listen to that and we'll start listening to that and pick it up the order 259 00:14:32,810 --> 00:14:34,580 ‫and if the payments failed. 260 00:14:36,440 --> 00:14:42,110 ‫It will write another topic, it will always write the topic and says, hey, payments failed and the 261 00:14:42,110 --> 00:14:46,940 ‫older service actually listens to the payment and to actually delete that, I think this is more elegant, 262 00:14:46,940 --> 00:14:48,620 ‫event driven architecture. 263 00:14:49,010 --> 00:14:50,200 ‫A lot of people talk about it. 264 00:14:50,210 --> 00:14:55,850 ‫I think it's a beautiful design, to be honest, and it's a really nice, elegant design to do this 265 00:14:55,850 --> 00:14:56,060 ‫thing. 266 00:14:56,060 --> 00:15:00,050 ‫And Kafka esque Kafka with distribution transaction people. 267 00:15:00,050 --> 00:15:06,200 ‫A lot more people are moving towards this architecture a lot because it's very elegant and nice. 268 00:15:07,400 --> 00:15:10,400 ‫Kind of has it has its own decoupling kind of a thing. 269 00:15:10,620 --> 00:15:10,830 ‫Right. 270 00:15:11,150 --> 00:15:17,360 ‫You still have the Kafka queue or the broker that does all that stuff. 271 00:15:17,360 --> 00:15:24,770 ‫But Robert complicated your stuff because you have to manage it out of Kafka is the one database. 272 00:15:24,770 --> 00:15:28,700 ‫But and the final solution is, believe it or not. 273 00:15:29,950 --> 00:15:38,350 ‫Go back to the old days, merge those dang services that are supposed to talk to the same database and 274 00:15:38,350 --> 00:15:42,740 ‫they are supposed to be homogeneous transactions in the same database, in the same service. 275 00:15:43,150 --> 00:15:47,540 ‫So go back to a mini monolith or a macro service. 276 00:15:47,590 --> 00:15:49,420 ‫It's a macro service in general. 277 00:15:49,420 --> 00:15:49,720 ‫Right. 278 00:15:49,720 --> 00:15:52,760 ‫Or a mini monolith, whatever you want to call it. 279 00:15:52,960 --> 00:15:57,490 ‫So the order and the shipment and the payment becomes the one service again. 280 00:15:57,490 --> 00:15:57,880 ‫Right. 281 00:15:58,360 --> 00:16:07,630 ‫But still, it's not does include every other things like shopping and cart service and product search 282 00:16:07,630 --> 00:16:08,950 ‫and doesn't include all of that stuff. 283 00:16:08,950 --> 00:16:09,180 ‫Right. 284 00:16:09,370 --> 00:16:14,850 ‫Includes all the stuff that everything kind of does the touching the database in a transactional manner. 285 00:16:14,860 --> 00:16:20,430 ‫So they use all the three methods that people are using to ensure distributed a transaction. 286 00:16:20,440 --> 00:16:27,010 ‫And when you say distributed transaction is is a transaction that spans multiple databases or spans 287 00:16:27,010 --> 00:16:34,600 ‫multiple services, multiple processes, not just A.D.A processes, doesn't have to be multiple services 288 00:16:34,600 --> 00:16:37,120 ‫on different computers or different containers. 289 00:16:37,300 --> 00:16:41,230 ‫They could be multiple processes in the same machine. 290 00:16:41,890 --> 00:16:44,700 ‫So that's kind of distributed in the main way. 291 00:16:45,460 --> 00:16:52,120 ‫It's not really horizontally distributed, but well, you can still you cannot achieve multiple transactions 292 00:16:52,120 --> 00:16:54,010 ‫with from different processes anyway. 293 00:16:54,010 --> 00:16:56,140 ‫So that kind of fall on the same track. 294 00:16:56,770 --> 00:16:58,600 ‫Let me know if that was useful. 295 00:17:00,310 --> 00:17:04,210 ‫Let me know if I said anything wrong or correct me if I said anything. 296 00:17:04,810 --> 00:17:06,670 ‫That doesn't really sound right. 297 00:17:07,030 --> 00:17:09,910 ‫I'm not really sure about the Google atomic clock. 298 00:17:09,910 --> 00:17:12,310 ‫I need to read more about it, to be honest. 299 00:17:13,240 --> 00:17:17,200 ‫But that was a summary of the transaction. 300 00:17:18,500 --> 00:17:19,320 ‫What do you think, guys? 301 00:17:19,850 --> 00:17:26,150 ‫Would you rather use a monolith and simplify your life or. 302 00:17:27,160 --> 00:17:28,120 ‫Would you rather. 303 00:17:29,250 --> 00:17:35,370 ‫Sacrifice and go to micro transactions and figure out how to distribute the transaction and figure out 304 00:17:35,370 --> 00:17:41,400 ‫how to minimize your latency, because now you spurt things down, you have network calls, you have 305 00:17:41,400 --> 00:17:46,620 ‫to figure that out and you have to also figure out how to debug your applications because debugging 306 00:17:46,620 --> 00:17:47,460 ‫is hard as well. 307 00:17:47,940 --> 00:17:48,290 ‫Right? 308 00:17:48,480 --> 00:17:51,450 ‫Because now the bug is no longer but a break. 309 00:17:51,450 --> 00:17:55,170 ‫But it's not it's not the same thing. 310 00:17:55,170 --> 00:17:55,370 ‫Right. 311 00:17:55,600 --> 00:18:02,790 ‫It's you have to put a attach a break debugger to this service and you need to know which exactly which 312 00:18:02,790 --> 00:18:07,010 ‫process to attach it to and also go to the other servers and attach the debugger. 313 00:18:07,140 --> 00:18:13,170 ‫And God knows that you hopefully you have one service of each one instance of each server so you can 314 00:18:13,170 --> 00:18:14,380 ‫nail debugging is hard. 315 00:18:15,000 --> 00:18:23,970 ‫So Data Dog and other providers and vendors are coming up with solutions like tracing and all that stuff. 316 00:18:23,970 --> 00:18:28,950 ‫Try to minimize, simplify these kind of things, but still micro services. 317 00:18:30,510 --> 00:18:34,870 ‫Communities, you have to do Bernardes, you have to manage all these daing containers, right? 318 00:18:35,290 --> 00:18:40,720 ‫So, yeah, yeah, I'm just very interested to see what where will micro services lead us. 319 00:18:41,190 --> 00:18:41,490 ‫Right. 320 00:18:42,550 --> 00:18:43,720 ‫So great architecture. 321 00:18:43,990 --> 00:18:45,390 ‫It's good to talk about it. 322 00:18:45,580 --> 00:18:50,470 ‫It's a really beautiful thing for nerds like us to nerd on. 323 00:18:50,740 --> 00:18:56,290 ‫And I just talk about Microsoft in general, but I don't know if it's feasible for every single one 324 00:18:56,290 --> 00:18:58,120 ‫of us or one to build. 325 00:18:58,120 --> 00:19:01,140 ‫Like Jenny, you want to build a donut shop. 326 00:19:02,200 --> 00:19:07,720 ‫Does she really need to spend up like Copernicus's Kluster to host her Statik website? 327 00:19:08,590 --> 00:19:09,250 ‫Probably not. 328 00:19:10,900 --> 00:19:13,260 ‫Yeah, I just like I'm just interested. 329 00:19:13,280 --> 00:19:16,900 ‫But the Googles and the Twitterers of the ward and the Facebook of the world. 330 00:19:16,900 --> 00:19:17,290 ‫Yeah. 331 00:19:17,590 --> 00:19:24,610 ‫They probably need this kind of micro services distributed so they can scale to the billions right off 332 00:19:24,610 --> 00:19:25,260 ‫request. 333 00:19:25,930 --> 00:19:30,220 ‫Yeah, I'm just very interested to know like how much would a monolith. 334 00:19:30,760 --> 00:19:31,150 ‫I don't. 335 00:19:31,150 --> 00:19:40,300 ‫Twitter reached a stage where they had to break down their micro services, their monolith they call 336 00:19:40,300 --> 00:19:42,820 ‫a monorail because it was built on rails. 337 00:19:43,540 --> 00:19:43,960 ‫Right. 338 00:19:44,530 --> 00:19:46,420 ‫Because they couldn't scale it out. 339 00:19:47,140 --> 00:19:54,490 ‫They that monolith was so big, spinning it up was so slow and just slow. 340 00:19:55,510 --> 00:20:00,100 ‫It doesn't it couldn't keep up with the requests, especially back in the World Cup. 341 00:20:00,100 --> 00:20:03,070 ‫2010 was it was year 2010. 342 00:20:03,250 --> 00:20:09,490 ‫I don't remember every time one of the Germany will score a goal or any any team will score a goal. 343 00:20:09,730 --> 00:20:11,800 ‫People will tweet Hegel. 344 00:20:11,800 --> 00:20:19,690 ‫And the moment do they do that, Twitter goes down immediately because this flux of just comes off all 345 00:20:19,690 --> 00:20:24,640 ‫over the world and the same exact second millisecond. 346 00:20:25,600 --> 00:20:25,980 ‫Right. 347 00:20:26,320 --> 00:20:31,810 ‫So, OK, let's let's just spin a more pvm there's been a more, but they couldn't keep up spinning 348 00:20:31,810 --> 00:20:37,050 ‫up more VIMS just spinning a single VM to hose this monolith just a couple of seconds. 349 00:20:37,060 --> 00:20:41,650 ‫And by the time it's spin up, it already filled up with requests, so. 350 00:20:43,100 --> 00:20:49,580 ‫They needed to break it down into micro services so they can scale the part that actually is busy and 351 00:20:49,580 --> 00:20:53,660 ‫instead of scanning the whole application, that is not like I mean, nobody's updating their profiles 352 00:20:53,660 --> 00:20:54,440 ‫in the World Cup. 353 00:20:54,440 --> 00:20:54,780 ‫Right? 354 00:20:55,130 --> 00:20:55,500 ‫Right. 355 00:20:55,880 --> 00:21:02,120 ‫The profile service just remains like in the single instance, whereas the actual rights service, whatever 356 00:21:02,120 --> 00:21:06,650 ‫it's called, the tweet service will will receive more instances. 357 00:21:06,650 --> 00:21:06,840 ‫Right. 358 00:21:06,890 --> 00:21:08,780 ‫So that's essentially where the how they did it. 359 00:21:08,780 --> 00:21:10,070 ‫And then it is very smartly. 360 00:21:11,930 --> 00:21:13,790 ‫All right, guys, that's it for me today. 361 00:21:13,820 --> 00:21:16,280 ‫Hope you enjoy this video and I'm going to see you in the next one. 362 00:21:16,520 --> 00:21:19,320 ‫What should I talk about next in the comments section below? 363 00:21:19,640 --> 00:21:21,950 ‫Give it a like subscribe if you didn't. 364 00:21:22,280 --> 00:21:22,730 ‫And. 365 00:21:23,950 --> 00:21:24,710 ‫Soon, the next one. 366 00:21:25,270 --> 00:21:27,250 ‫You guys stay safe, stay awesome.