WEBVTT

0:00:16.281 --> 0:00:23.234
<v A>Programming Throwdown Episode 125: Object Caching Systems. Take it away, Jason. Hey.

0:00:23.774 --> 0:00:37.920
<v B>Everybody happy New Year! Happy New Year, Patrick. Thank you. Do you have any New Year's resolutions or—I feel like that word is abused—but do you have anything you want to do this year that's special? I mean, I...

0:00:37.920 --> 0:00:50.959
<v A>I have tons of stuff I want to do, but I don't make them resolutions because I mean, we've seen in the last two years it's very hard to predict what's going to happen. But no, I'm not a fan of like start exercising just because the date rolled over, like.

0:00:50.959 --> 0:01:33.113
<v B>Yeah, exactly. Should always be doing it. So is there anything really particular, like a skill you're trying to build or anything like that? Oh man, you put me on the spot. I should have made it before. I'm sure I could have thought of something. I'll put myself on the spot. I think, you know, one of the things that I want to do is—I want to get back into reading, you know? I feel like oh, so one thing is that, you know, I'm going to probably go back into the office, into an office, you know, this month, and so it'll be an opportunity for me to get back into reading books, which—it was kind of hard to do. I was so used to doing that on my commute, and when I lost the commute, I, you know, still read books, but just, you know, not at the same pace, and so I want to—I want to kind of use the commute to bring that back.

0:01:34.176 --> 0:02:02.492
<v A>That's actually funny because my book of the show, I won't spoil it, is the first time I actually got a Kindle during Black Friday sales and put a book on it. And it was the first time I bought something like a book but a Kindle book—ebook, yeah—the first time I had read something on a device like that, like not a physical book, and actually like read it just like an entertainment book, not just like flip through or reference something, but actually downloaded the book, like read the book cover to cover. And you know, did it during the break off between, I guess, Christmas and New Year's. So yeah, that'd be a good.

0:02:02.492 --> 0:02:13.731
<v B>One for me too. Wait, so this happened this year or you're saying this is recently? Yeah, like a week ago or two weeks? Oh, yeah. So what's your take on E-Ink versus a display? So what I...

0:02:14.895 --> 0:02:34.487
<v A>will say is so I just bought the cheapest Kindle because I didn't know if I would commit to doing this, and so it was a bit of an experiment. But I'll say it has a light on it that's a game changer because you can sort of like—I would wake up in the morning and without like rolling out of bed, I get to be like, 'Look, I don't want to go get my phone and all that like I'm going to see my text messages.'

0:02:34.487 --> 0:02:35.299
<v B>And my? Yeah, right.

0:02:35.299 --> 0:03:15.240
<v A>Instead, I would just like pull it out and like I'm going to just read a chapter or read—read a few pages, you know. Or in the evening, the same thing. And I'll say that it sounds so goofy, and everyone says it, and everyone's right, which is that you have less distractions on an e-reader, and the E-Ink looks really good, so you can read it if you're in the sun or in the dark, and there's just not other things popping up and asking for your attention or distracting you. So I don't know, I'll let you know at the end of the year, but yeah, I too am striving to try to do a bit more reading. I—I am not returning into the office imminently, so yeah, I—too need to fill that hole very.

0:03:16.067 --> 0:03:49.750
<v B>Cool. Yeah, I actually—I'm thinking, so I was—I guess thinking about just buying an e-paper like thing I could run Linux on or something like that. But yeah, maybe I should just go the road much more traveled and buy a Kindle and not cause so much heartache. I was thinking that I would have an E-Ink display that would be an e-reader, but I could also use it as kind of a desk calendar and just leave it on my desk, and it could show me my daily like schedule. And maybe Kindle can just do that? So maybe someone's written that program for Kindle? I'm...

0:03:50.357 --> 0:03:57.940
<v A>Specifically trying not to do that, so I will stay in the not distraction proper use of the thing for this one, but that does sound cool.

0:03:57.940 --> 0:05:51.179
<v B>Cool. Yeah, one thing that I did over the break which I wanted to share with everybody is—I so I personally was spending like over $200 a month on public cloud stuff because I have—I have a whole bunch of sites. I have, you know, Programming Throwdown. Um, I also have a site for Maim Hub. I have a server for Maim Hub. I have a whole bunch of different projects all running on the cloud, and the thing that was really costing me a lot was databases, which is actually going to be some of the things that we're going to talk about, a part of what we're going to talk about today. But you know, I was spending like over $100 a month on databases, and some of these projects were either, you know, either dead or—or, you know, they were projects that we were running just at this point just me and my family are using it, and so I haven't really taken it mainstream or anything yet. And so I was able to really massively reduce the cost. So there's a whole like we could do a whole show on trying to reduce your cloud costs, but—basically there's you know getting your own server. So you have a server, it's running, you know, Ubuntu or Debian or whatever, and it's just there 24/7, and it's just sitting in, you know, Google's data center, Amazon's data center—what have you? That's like the most expensive, right? And then there's you know getting a dedicated service so like a database. Um, you're having a MySQL database kind of in the cloud, and that you know they cut you a little bit of a deal if you go through like Amazon or Google, but still pretty expensive. I mean, for one server, you know, you're looking at, you know, at least like $50 a month. And then there's the sort of kind of pay-as-you-go approach where you use things.

0:05:51.179 --> 0:07:38.963
<v B>Like AWS Lambda, where you can say, you know, here's like a single Python function, and whenever the trigger happens, I run this function. But if there's no triggers, then I'm not paying anything. And for a lot of the small projects I had, that would be way, way cheaper, right? Because a lot of these machines were sitting idle. But I didn't really know what there was in terms of databases. You know, is there a database where, you know, sure if it got super popular, I could get hit with a big bill, but you know, I could at least be there until something got popular. And I found a couple which I wanted to share with everyone. So for SQL, for things like MySQL and PostgreSQL and all of that, I'm using this thing called PlanetScale, and they have a very generous free tier. And then I think there's a flat fee. I want to say it's like 10 or 20 a month, and you can get more databases and all of that, but it's also a pretty generous flat fee. The thing is, you know, as you if you start, you know, they count the number of rows you access per second and so if you or per month, I guess. So if you start getting a lot of rows per month—I think it's like hundreds of thousands at that point—you know, this is read or write at that point they start charging you. And then for object caching systems, I'm using Upstash, which has like Redis as a service. And for the moment, I'm still on the free version of Upstash because I, you know, I'm not doing the caching too heavy yet. But yeah, I found both of these to be really nice and the way they've done it. Actually, PlanetScale was clunky when I first tried it about six months ago, but I went back to it a week ago, and it's now become extremely nice. It's very similar to just having a MySQL database. There's really nothing you have to do special, but yeah, check these out. I think these are amazing projects that's really cool.

0:07:38.963 --> 0:08:22.889
<v A>So that may or may not lead into stuff we talk about later, but database caching. Yeah, that's pretty cool. Have you ever thought about for some of that stuff like the rage? I will at least my stuff I pay attention to would be like self-hosting some of that stuff, like having a computer you could just run Docker on and letting people do that. I mean, I don't know depending on what usage patterns you have. I've been looking at this like WireGuard VPN as well, which would—there's a variety of people spinning up around that VPN basically letting people appear as if they're in your home network, but easily for like relatives and stuff, even if you didn't want to expose it to the public web. Is that something you considered or just a bit too far off of what you normally do?

0:08:23.159 --> 0:09:47.220
<v B>I mean, the thing about it is it's actually kind of difficult to administer a MySQL server. You have to do a lot of setup, and then, you know, every time you update the OS there's like a chance you break the server. So I ran—I ran MAMEHub off, you know, just a regular VPS, like a regular, you know, machine in the cloud running Ubuntu. And so MAMEHub had all of these things, had MySQL, it had Redis, had everything running, and it wasn't using Docker, probably should have been, but yeah, definitely without Docker, like, you know, it was breaking. You know, maybe like once a year or so I would have some big break, or like the hard drive would fill up or something like that. There's just like all these small reasons where you could get kind of burned, and then you have to kind of spin up on, oh what did I do here? And oh, like, you know, the files—I forgot what they are—and everything. So this is nice because the worst thing that could happen is you can get hit with a high bill. I do recommend folks turn on the—there's a thing you can turn on where if the bill goes above a certain amount it shuts off. I mean, definitely take the five seconds to like go to the Cost Explorer and like set some ceiling on all of these things because you just never know. I mean, it could be like a DDoS attack or something, and now all of a sudden you have some big bill. But provided you do that, I mean, these things will should, you know, be up forever. It's like Upstash; I set it up six months ago, and to be honest, I even forgot the name of the company or anything because it just been working for six months.

0:09:47.220 --> 0:10:31.172
<v A>That's funny. Yeah, you remind me of the story of the guy when GPT-2 came out, the like natural language deep learning trained model, and you could give it queries, and he was doing like a sort of crude RPG over it where you could kind of just do anything you wanted, and it would respond, and he was running it—I don't remember, I think on AWS or something—and it got super, super, super popular. And I forget how obscene his server charges were initially, and same thing like you said. So I guess like that's always possible. So definitely try to make sure you set some sort of upper limit even if it's pretty high just so you don't end up waking up to a seven-figure server charge. Yeah.

0:10:31.695 --> 0:10:56.200
<v B>mean you can easily end up with a hundred thousand dollar bill i mean it's it's it's if you have some website that goes viral or gets dossed you could get hit with a huge bill so it's definitely good advice to do that yeah that's pretty funny uh you know i think gpt2 is not light i mean it's a giant like hydra you know huge neural net that's pretty wild so what did he do did he negotiate his price down or do you know

0:10:56.215 --> 0:11:19.334
<v A>Yeah, I mean, I think those ones that get like famous, famous they sort of, you know, someone behind the scenes makes it—makes it not a big deal when a college student sort of says, oh, you know, I don't understand. They don't want the bad press. So I'm sure yeah, behind the scenes it just sort of got taken care of and, you know, someone showed him politely how to set his bill limits to something more reasonable. Yeah.

0:11:19.637 --> 0:11:51.280
<v B>That makes sense, but yeah, don't let that be you because I don't know what would happen if you weren't famous or maybe they just didn't want to change the bill. Like it would—well, we've heard stories like this with cell phone right where I remember a person was operating a crane in Alaska and they were roaming the whole time and they were streaming YouTube videos for like a month. They got some enormous bill, like 70k or something, and yeah, that made the news too. And I think they negotiated it down to 2000 or something. But but yeah, be careful for that; that's always an issue.

0:11:51.280 --> 0:13:46.281
<v A>Speaking of reasons why you might also end up running unintentional code, this month has been pretty bad for Log4j. So this is Log4j. I've actually used this framework before. Yeah, same here. Oh, okay, it's like super popular and basically it does a lot of really fancy stuff in Java to allow you to manage your logs, set verbosity levels, and, you know, do smart tokenization so that you can insert, you know, data and just have better logging output. Which logging is always just one of those things that's very difficult to kind of do really well. So Log4j as a framework was super, super popular, and of course run in not exposed to the public, but on services that were exposed to the public because pushing your logs up is one of the ways to debug if something goes wrong. And so making sure that you know servers are logging out information they're doing and that you can triage them is super critical. And they ran across three in the last—I think sort of month vulnerabilities, and I was telling Jason before the show we were talking about it. It's actually a bit difficult because I got so mainstream to find actual engineering discussion of what happened, but I have a couple links in the show notes. And basically the exploit was if you could insert a certain token into something you sent to the server and that token could get logged, Log4j would try to take action to unparse that token. And so I think Minecraft for instance got a lot of news because someday people are going to look back and talk about Minecraft as, you know, rivaling the biggest things and crazes of the 80s and 90s. Oh yeah, for a long time now it's crazy how long Minecraft has been going on, Jason, and I—you and I played Minecraft what, 11, 12 years ago or something? I don't even know when it first came out, like super long time ago now. Yeah, it's still popular with kids today. Yeah.

0:13:46.332 --> 0:14:10.328
<v B>I was terrible at Minecraft. I mean, I just didn't have the patience really because I didn't realize that you had to look on the internet to find the crafting recipes, and so I tried a few different random putting things in the boxes, and I couldn't figure out how to make the craft. I see. I think I—yeah, I couldn't even figure out how to make the crafting table, and I was like, 'Okay, you know, I think we're done here. There's no one's ever going to play this.' I remember you.

0:14:10.969 --> 0:15:48.962
<v A>Telling me about it on a work trip that had to have been over a decade ago. But anyway, so Minecraft's super popular. Okay, I was gonna swing back on topic, and I think people were finding out you could send chats to each other in Minecraft, and if you send a chat that has a certain string—just like the classic, you know, sequel unsanitized stuff—and getting SQL exploits, you could say like, 'you know dollar curly brace' and then some URL. And basically what would happen is Log4j would go, 'Oh, I need to resolve this. Oh, this is a URL I need to reach out to this URL to figure out the value of this variable.' And then the URL could return a, you know, custom Java bytecode class for you to run. And that bytecode class we could just do anything. And so this is obviously super, super bad code injection. Run whatever you want. Wow, wow, that's wild. There's like one of those like worst possible like nightmare things. So I put in here some explanation from JFrog who they actually recently went public with Artifactory and stuff, but then also a link in here from Microsoft which, of course, getting some of this heat from Minecraft, which all the Microsoft hosted ones were patched very, very quickly. But we were just talking about hosting lots of other people are running Minecraft servers that are still vulnerable because they were relying on this vulnerable Java version, but they were also discussing there how much logging they were seeing of people scanning for this vulnerability, so just hitting random endpoints with various things and trying to see if they could get ping backs from your server, which would mean your server was vulnerable. And then they could decide, you know, what to do once they had a list of all of the—how would they?

0:15:49.080 --> 0:15:52.607
<v B>Know if you're running Log4j whatever the service is? So I mean,

0:15:52.607 --> 0:16:52.767
<v A>think you could just find anyone, for instance. And I—it didn't go into this level of detail. It's not my background, but I can imagine going to every IP address, going to port 80, and then like many of them are going to respond with some pre-canned server something that you could recognize, and then sending back like, you know, Jason's whatever—oh MAMEHubMAMEHub.whateverJasonuses/you know? equals, and then just putting like, you know, this format is string, and many servers it's very common to log the endpoint or to log the query params or whatever. And so if you have one of these in the query—but not I'm not 100 sure that would work—but you can imagine someone going to every port 80 exposed that had a signature that or fingerprint that matched some common open source host that uses Log4j, inserting into the query params and then having a payload which says 'ping back my URL,' and anyone who pings back, you know, they would sort of insert into a database somewhere for later, you know, deciding what to.

0:16:53.678 --> 0:18:51.960
<v B>Do yeah, that totally makes sense. Yeah, I probably need to check Maim Hub for this how that we talk, but actually Maim Hub's running all Python and Flask and stuff, so I should be okay. Okay, but until it turns out secretly Flask is running some Java. Yeah, that's right. Flask has a of a module, a Python binding module. Yeah, that is wild, man. Very cool. Yeah, I always wondered that. Thanks for explaining all that. So my first article is scan of the month, and this month it's Game Boy. There's some weirdness around the URL, but the URL I posted in the chat should stand the test of time, but they actually use CT, and I don't know very much about—I mean, I know ostensibly MRI is magnetic resonance. I don't know actually what CT is, isn't it computed tomography? Oh my gosh, look at this, man! I put you on the spot, and you nailed it. I don't actually know under the hood like yeah what those really mean, but anyway, they use CT to scan a bunch of computer components, and this month they did a whole bunch of Game Boys, like the Game Boy original, the Game Boy Color, the DS, the DSi. And they use the CT, you know, scan to extract all different layers of PCB, and then they just go through explaining, you know, at a hardware level all the different, you know, components. And it's really cool to see over time how they kind of integrated everything. Like the earlier ones, it's like, okay, here's all the buttons and here's the D-pad, and there's little traces going all over the place. And then later on, it's like, okay, we just have this chip that's doing everything, and like literally all the traces are just going to this one place or they're baked into the board or what have you. But yeah, check it out. I just—I don't know very much about hardware, but I got a really kick out of reading this, and the graphics are beautiful work. Should work on the phone and on the computer. So I read.

0:18:51.960 --> 0:18:55.650
<v B>It on the phone, and yeah, give it—give it a read. It'll be worth.

0:18:56.444 --> 0:20:10.139
<v A>Five minutes. Yeah, that those artwork in there is really cool. The way they did it, the presentation of the website is fun, but it definitely has pretty pictures, something that I was surprised about, and it turns out it's rather common. So not CT scans—I mean, those are very involved—but X-ray actually for people who do a lot of like electronics assembly, it's very common to X-ray boards and look for defects. So when they make the printed circuit boards, like the you know where all the traces are, you have multiple layers. So you can only see stuff that's on the sort of like exterior layer, the bottom layer and the top layer, but you can have middle layers. So I think for like your motherboard in your computer, it's common to have five plus layers internally, like over top of each other routing ground planes, all this stuff, and you can't see that from the outside. So if there's a break or an issue, you wouldn't be able to detect it. So it's actually very common to do X-rays of electronics and look for, you know, places where a trace is broken or isn't routed correctly or something is happening. And so doing those kind of—I thought that was limited to when you go to the dentist and they do that, you know, X-ray, but apparently doing sort of real-time on-demand X-rays is more common than I would have.

0:20:10.964 --> 0:20:13.529
<v B>Thought. Yeah, that's wild. I didn't realize X-ray would.

0:20:14.372 --> 0:20:25.500
<v A>Be that precise. My next news topic is not really a news topic, but something that came up and then I'm for some—it was alluded to by some article I wrote, so I decided to talk about it here, which is Hyram's Law. Have you heard this before, Jason?

0:20:25.830 --> 0:20:26.674
<v B>No, I haven't.

0:20:27.282 --> 0:22:24.719
<v A>So okay, I'm gonna—I'm gonna read it directly or else I'll end up misquoting it. So Hyram's Law says that with a sufficient number of users of an API, it does not matter what you promise in the contract; all observable behaviors of your system will be depended on by somebody. So this comes up from time to time when you do software engineering. There always is like Mythical Man-Month, Hyram's Law, the networking issues—you get into all sorts of things where everyone keeps rediscovering it. And this is one of those ones that I had run across but didn't have a name for it. Now I have a name for, and it's Hyram's Law, which is if you make your system behave in a certain way, if enough—if it gets popular enough, everyone will depend on every quirk, intended or unintended, of that system. And so the person you can go to the website credit sort of where they got it from and these kinds of things. But people were chiming in an article I was reading with all manner of examples. So if you go back to like the old Nintendo, the NES, that like certain quirks of how the graphics rendering became like super important. So in a later revision, if they had fixed the silicon and fixed that quote-unquote bug, everything would have stopped working. You know, there are certain weird opcodes or low-level device drivers that just do certain things at certain time because that's the way they always were, but then you can't change it because everyone does it that way. And so if you fixed it later, you'd break other people's stuff, and it doesn't matter whether you wrote that down or not. If it behaves that way, it's going to act that way. We ran across this recently, and I was bringing it up to somebody. It's not exactly the same but in the same ballpark, which is somebody was iterating a hash map. Of course, like how things are inserted to the hash map could vary for many reasons, but it shouldn't be something you ever rely on. It isn't a contractual obligation.

0:22:24.719 --> 0:22:35.751
<v A>For like if you insert in a different order, if you do whatever, if you need a stable visit order, you have to do some sort of sorting or some guaranteed way. And a hash map is not that. Yeah, I.

0:22:35.954 --> 0:22:57.317
<v B>Think I think in Python there's like a special structure called—it's either called Stable Hash Map or Ordered Hash Map. I think it's called Ordered Hash Map. And so ordered hash map when you iterate over the keys, you get them in the order you put them in. I still don't understand why anyone would want that. It keeps like a linked list, like it must. Yeah, it must keep a linked list in addition to the map in the.

0:22:58.195 --> 0:23:19.457
<v A>Background. Okay. I mean sure, but needless to say. So we ran across a test where someone was putting stuff in a hash map, iterating the hash map, and then basically asserting in a kind of like unit test that like the results were in this order, and I pointed out to them like, 'This is really bad.' Like super fragile. Like you know, this is overly.

0:23:19.592 --> 0:23:21.550
<v B>Simplified or sorted afterwards or something. Yeah.

0:23:21.972 --> 0:24:04.463
<v A>Sort it, do something, or do a check where you don't rely on the sorting; just check that it's present, right? Yeah, because yeah, that iteration can change at any time. But I think you could easily imagine building two or three layers up to where when you call an API, you say like 'Give me a random user,' but actually the random user always gives you a sorted list. Somebody somewhere isn't going to realize it was supposed to give you a random user, and they're going to assume that if they keep calling it, they always get them sorted, and they're going to depend on it because it's never been otherwise. So this is putting a name on one of those things I've always kind of known for years and run across many times, but this is—it's good to have a common language for it.

0:24:05.054 --> 0:26:03.212
<v B>Yeah, we see this a lot. So a lot of people are curious when they find out that MAME actually gets more and more inefficient as you move up in the versions of MAME. For example, like the most recent version of MAME can't run on a Raspberry Pi, but you can run, you know, MAME from 10 years ago just fine. And even, you know, the same game will run just fine if you're on the current MAME, it won't work. And the reason for that is because of all of these things where, you know, they kind of use various tricks to take advantage of, you know, the way the hardware was set up. And so you have to emulate kind of all of these tricks perfectly, and it becomes really time-consuming. And there's one in particular people should check this out: Contra, the arcade version of Contra. In the actual arcade, the bullets would flicker, but the flickering was caused by just the different processors running at different speeds, and so they just thought it kind of looked cool or maybe they shouldn't, you know, didn't have time to fix it, and so they kept it. But for a long time in MAME, the bullets would not flicker, and so they actually like did all this work to make them flicker, and it became like really computationally expensive to do that. But yeah, it's similar to this law where it's like people either took advantage or they took artistic liberty with the situation that they had on the hardware side, and then recreating that ends up being really hard. My second story is Make the Internet Yours Again with an Instant Mesh Network. So I haven't tried this. Full disclaimer, but I love the idea just to give a bit of backstory. So, you know, a long time ago they invented IPv6. And the reason why IPv6 is cool is because, you know, well, okay, if you go back even further, every machine had a public IP address for that machine. So, I don't know how far back you have to go for this to be true.

0:26:04.461 --> 0:26:29.892
<v B>But, you know, you would have, you know, 27.27.27.27. Like that was you. And so anytime anyone, you know, ping that, they would get your computer that you're, you know, on right now, or your phone, or whatever you're on right now when you're listening to this. And so you could just run a web server or an email server on your device, and that's it. You'd be done. It's like, okay, I have my web server on 24; anyone can just go there and see my

0:26:31.782 --> 0:28:26.740
<v B>website. Well, people started running out of IP addresses because there's, you know, there's a lot—right? There's 256. Well, you know, the number space is 256 to the fourth. A lot of those addresses you can't use for a variety of reasons, but there's still a decent chunk of addresses, but not enough compared to the number of machines that we have on the planet Earth, right? It's not even close. So all the machines that have ever existed because you don't really know when a machine has been decommissioned, right? So they proposed IPv6, and this just adds, you know, a ton of bytes, you know, bits to the address space. And so with IPv6, in theory every machine could be accessed directly. So, you know, you could have a machine that's at your house, and someone out there on the internet in an internet cafe could just like go to that machine and just see what ports are open and everything. And so yeah, one thing to keep in mind is, you know, because—so actually just doubling back a bit—so to deal with this address space issue, we created NATs, Network Address Translators. So, you know, a portion of the internet address space is blocked off for internal addresses. And so, for example, in my house, you know everything is 192.168.something.something. And anything after 192.168 is going to be some internal place—could be someone's house, could be, you know, a business, right? But there's maybe hundreds of thousands of devices that have the IP address, you know, 192.168.0. I guess that's to be at least one. So, 192.168.01—there's tons and tons of devices with that address. But what happens underneath is is machines go to let's say your house. So,

0:28:26.740 --> 0:30:10.684
<v B>let's say one of these machines with these with the same address tries to reach google.com. They ping Google, and all the machines on the way keep track that that machine wanted to talk to Google. So let's say you have, you know, 192.168.0.1 is your phone. Your phone talks to your router, which is running on let's say that address .2, and the router keeps track of that phone wanting to reach Google. And then that router then goes to your ISP. Your ISP has another router which does the same thing. And then when Google replies with, you know, their logo and all that, all these machines know who needed it. And there's a whole bunch of complexity around that, but that's how that translation works. The problem is there's no way to go the other way. So like if Google wants to send a message to your phone that isn't a reply—that's just an organic, you know, first message—they don't know which 192.168.1 is is your phone and not someone else's. And so there's just no way for them to talk to your phone. Now that's good for a security perspective, but it's bad from a, you know, running a server or doing something, you know, distributed hash table or anything like that in your house. And so what this system does—it's it has a weird name. It's named after one of the HP Lovecraft monsters, like Yagrassle or something. But isn't Yggrassle the Nordic Tree of Life? Oh, okay, it is. Yeah, I think that's mythology. Oh, isn't there a HP Lovecraft monster that sounds very similar? That's Cthulhu. No, no, there's one that starts I think with—let me look.

0:30:10.920 --> 0:30:17.639
<v A>It up. I think Yggrassle is the Nordic Tree of Life, but anyways continue with branches and connectivity. I think it probably goes along with the

0:30:18.599 --> 0:31:40.320
<v B>Oh, it's actually there's one just called—yeah. Oh, I know. Oh yeah. So they probably just stole it from that, but anyways, so Overload. Yeah, yeah, they overloaded. Yeah, they needed IPv6 for their, you know, monster names. But yeah, so check this out. I mean, you know, as I said, it's going to basically make your any machine that runs this is going to be exposed to any other machine in the whole world that's running this. And so what that means is you probably want like a firewall or just like, you know, if you're running a server or something, you want to be really careful about this. You know, some people at their house they might run a Samba or a network file share and leave it totally unprotected because of this they don't have to worry about this address translate—or the address translation is kind of protecting them. This will kind of strip off all of those protections. So, you know, use this kind of understand what you're doing. Maybe run it in a Docker container first. But yeah, I thought this was really cool, and you know, I think the reason why IPv6 has never really taken off is all of the security nightmares that would be downstream from that. But but yeah, this will allow you to without having to do a lot of complicated port forwarding just access all the machines in your house from anywhere, which I think

0:31:41.860 --> 0:33:38.145
<v B>is kind of cool. Is it time for Book of the Show? Book of the Show. My Book of the Show is an amazing book. I've loved this about halfway through it, and I'm a really, really big fan. I love the format. You know, I think they did an amazing job with this. It's called AI 2041, and the premise behind the book is they're outlining different things that they think could be real in 2041 where AI has just advanced like a massive clip. The book is broken up into chapters. Every odd chapter is an independent story because it's a set of short stories. I can't, you know, I don't want to spoil any of them. You know, there isn't a plot that covers the whole book. It's like think of it: each odd number chapter as its own small book with its own beginning and end. And then every even chapter is Kai-Fu Lee, who ran Google Asia Research, Google Research Asia, and he goes through and explains the technology in the chapter you had just finished, and he kind of like explains it as if you're a total lay person. I mean, he goes into what is a neural network and everything. So I found that like really, really cool. Like Dynamics. So the stories are all fiction stories obviously, but not only that—they're dramatic. So, you know, without spoiling too much, there's a story about these twins who their parents are killed in a car accident, you know, when they're babies, and so they get taken to an orphanage. And it's about them growing up in this orphanage and how, you know, AI has massively improved sort of education and especially in like kind of orphanage situations. You know, they they have sort of these AIs that kind of care for them, like in addition to the people and everything. So yeah, I mean, it's it's like I could see kind of something like that happening where where AI can be sort of like a teddy bear, like a buddy for somebody as they're as they're little.

0:33:38.517 --> 0:35:13.962
<v B>And and all of them are plausible. I mean, I definitely think that they really push to the limit how much progress we would have to make, but nothing is totally fantastic. Like everything I think is doable in 20 years, and at least from the chapters I've read so far. One chapter which I thought was kind of funny was there was a person who or they're a driver for self-driving cars. So the idea is, you know, self-driving car gets stuck in an intersection, and this person sits in their house and they have a steering wheel and a computer, and their whole job nine to five is just taking over from cars that are stuck. And so they were—they were recanting kind of their career when their career started. It's like, oh, a car is stuck at a stop sign; it's just confused, and so he just takes over. He just, you know, looks around using all of his monitors. There's no one in the intersection; he just drives on, and then he hands the control back to the AI. But now it's 2041, right? I mean, it's—I don't know, 15 years later or something from when this person got their job. And so now the situations they're in are just crazy. It's like it's like, oh, the car needs you to take over, and he jumps in, and the car's like on fire, you know, and so and so his job has turned into doing just crazy things all day, just like death-defying things all day, and and it's he gets some PTSD from it. So, I don't know. I think the whole book is really interesting. Highly recommend it. Oh, that's that is I'm gonna

0:35:13.962 --> 0:35:14.974
<v A>add that to my list.

0:35:15.480 --> 0:35:17.978
<v B>Yeah, you can read it on your Kindle and let us

0:35:17.978 --> 0:36:12.417
<v A>know how it is. There we go. So talking about books I read on my Kindle, which I've never read the illustrated books. I don't know how that works yet, but I read Dawnshard by Brandon Sanderson. So as if you know anything about Brandon Sanderson, he's a prolific writer, but also his books tend to be kind of long, and as if they weren't sort of long enough, the current series that I've been working on, The Stormlight Archive, is supposed to be 10 books in total, two five-part books. But then between each set of books he releases, he's like releasing like a novella between them. And so this is the one between the third and fourth book, The Words of Radiance and Rhythm of War. So it wasn't a—it's a novella, but it's still I guess I'm looking here on the internet says 269 pages. 269 pages is considered like the short book between the like other books on either side of

0:36:12.417 --> 0:36:13.024
<v B>it oh my

0:36:13.024 --> 0:37:05.657
<v A>Gosh, it's like three point book 3.5. Um, but Book Four itself—I mean, The Rhythm of War—I forgot how it's like 1200 pages. I think we were talking about it before. Um, so anyways, I read this on my Kindle, A Lower Commitment than Reading Full Rhythm of War, which is what I've started now. Um, but this was an easier thing, and I read it, and this book was really good. Um, obviously not a recommendation for people who haven't read Books One, 1.5 to 2.5, 3, and 3.5. But you know, if you're in that series, definitely worth a read. Some people don't read the in-between novellas, but I like to because if you don't, I feel like you miss stuff. So I enjoyed this. This is one of those important and good for me and people in the know, but everyone else is like, 'Yeah, this is not a useful recommendation because I'm not gonna jump into the middle of this huge long many thousand page epic.' So well.

0:37:05.978 --> 0:37:18.837
<v B>No, I've definitely—we've gotten emails from people who either got into, you know, your interests, your reading interest. I've like adopted some of your reading interests, or they're already there, and the show really, you know, connects with them.

0:37:20.035 --> 0:37:32.117
<v A>So yeah, I've gotten some recommendations from people as well for good series that I've read. Unfortunately, my reading was—as we talked about—the top of the show has been severely diminished recently. So I'm trying to get back on the train; gotta make it through.

0:37:34.294 --> 0:38:02.661
<v B>My backlog. Cool, man. All right, onto the tool of the show. I wonder if we should pay like get an announcer or use Amazon Polly or something to get a real announcer voice, or we should just keep doing that 'Let us know, send us an email.' Horribly bad fiber. Yeah, do you want us to pay an announcer to do that? Or I wonder if Amazon Polly has an announcer voice, or you could just type something into Amazon Polly and it would—I don't.

0:38:02.661 --> 0:38:03.927
<v A>Know what this is?

0:38:03.927 --> 0:38:07.184
<v B>Oh, Amazon Polly is just a speech synthesis program. Oh.

0:38:09.023 --> 0:38:10.069
<v A>Yeah, there it.

0:38:10.289 --> 0:40:05.612
<v B>Is yeah. So my tool of the show, which is—it's never going to sound as cool for me as it does from an announcer guy is Swagger, which is now rebranded as OpenAPI or at least part of it. So um, so I used Swagger a long time ago, and it's really come a long way. I was working with another team at work that had a Swagger, had their stuff running, and Swagger is really impressive. And so basically the way it works is, you know, if you want to have a web service—so something where someone gives you some input, you know, some set of arguments, some instructions, and then you return back some kind of also output, and nothing too crazy like a media or anything like that, just as simple. You know, person gives you some JSON arguments and you spit back some JSON output. And then on your actual server, you could be doing whatever you want—something that is pretty standard, right? Because you don't know what languages people are going to be using when they're calling your service. And so you can imagine just like yeah, taking in a JSON or, you know, blob and then outputting a JSON blob. But then the problem with that is it gets really generic. Like people could put anything. They might mistype one of the keys right of your JSON object. They might just have a typo in there, and so that becomes kind of difficult to debug. Like you have to write all sorts of logic to handle that, and then also to make sure you produce the right documentation. So you tell people, you know, when you call because they probably won't be able to see your source code, or it'll be cumbersome for them to have to go through your source code. So you want to be able to tell them like, 'Look, you know, I expect this JSON object and I expect this key called FooBar,' and the F needs to be capitalized, and etc. And so.

0:40:06.270 --> 0:40:45.944
<v B>Swagger is a way for you to sort of write up that contract, and then it'll automatically generate, you know, a website where people can go and read more about how your API works. And then this is where, you know, I don't want to spend too much time on this, but basically, you know, they created this standard called OpenAPI. There's a whole bunch of tooling there. There's tools that Swagger, the company has, that lets you test your API, you know, from the outside and everything. So definitely check this out if you're building a service that you either want to consume from some other language or, you know, you're building something for other people. Definitely, you know, check these things out; they're super powerful.

0:40:46.821 --> 0:41:27.051
<v A>I've used some stuff that had this. I'm not written a ton of the sort of what do you—what would you call that? The metadata you need to generate them. Although I have a little yeah, but I've used that or some things. Okay, but I have used some that had it, and I do really like this thing you're saying where you can sort of go to it and have it guide you through what you're expected to send then get back. Super powerful. And I can imagine like keep going this way and then having tools to like auto-complete your code for like how the expression should come in and like what's expected, and not when you start linking to serve like one day we're not there, but like one day in my head it's going to be a beautiful place where everything's going.

0:41:27.051 --> 0:41:53.560
<v B>To happen. Yeah, that's a genius idea. I bet someone's written that like a Visual Studio Code extension where you kind of give it the Swagger URL, like the, you know, the documentation URL that you're trying to access, and then they could do—they could do tabbing for you. And so that would be amazing if you're out there and you're looking for something to build, and this doesn't exist yet. That would be phenomenal, and it probably wouldn't be that hard to build.

0:41:53.560 --> 0:43:52.940
<v A>Oh, famous last words. We can't guarantee that last part. My tool of the show—I thought I mentioned it before—I couldn't find it if I did. Oh well, it's worth mentioning. I haven't heard of it. Oh really? Okay, this is Ripgrep. Now you're probably sitting there like Jason saying, 'I use only the most powerful awesome Unix tools and I don't need anything that isn't POSIX compliant and shipped with my BSD install.' I'm not such a user, so I have found this tool enormously helpful for searching around my code. Ripgrep promises to do a lot of things, many of them interesting, including being faster. But the thing I love Ripgrep for is that I can search the directories I have recursively by default and also honoring my .gitignore and ignoring binary by default. Now, I'm 100% sure you can do the same thing with grep. I don't know how fast or slow it would be, but that incantation is beyond me. So I can do Ripgrep, which I have is just `rg`, and then pass it a `-i` flag if I wanted to ignore, use the capitalization of my query type in the word I want to search for, and get back in my Git repositories all the places I've used that keyword. And so wow, this is so cool. Yeah, apparently there's a bunch of other tools that were listed there that I learned about from going to their website and preparation from here things like SilverSurfer and other things that I guess also do the same thing, but I've never used those. Ripgrep says it's faster than all of them. The speed is good; I've never been bothered by that, but just this ability to automatically ignore binary files, automatically ignore things. For instance, we have build folders that hold outputs, and whenever you search if you forget and you just type `grep` and then you do it recursively, you end up getting a lot of outputs from the build folder, you know, inputs that were copied or, you know.

0:43:52.940 --> 0:44:16.679
<v A>zip file, whatever all these kinds of things, and you don't want them. And so Rip Prep will ignore them because they're ignored, and they get ignored. And so that's super powerful. Um, and also it does have ability which again I'm probably can do in other things, but to like go into even compressed stuff. So if you were trying to search dependencies and you're using something which brings in dependencies as compressed, then it'll be able to handle those things as well. Wow.

0:44:17.370 --> 0:44:37.958
<v B>You know, that is amazing. I'm definitely going to use this tool. The other thing that this site had which blew my mind is there's grep inside of Git. So you can type `git space grep space` and then do grep inside of git. I also didn't know that. But does that work if you're not in a Git repo? Like, no. I have like some—it's only for Git repos.

0:44:38.582 --> 0:44:49.315
<v A>Okay, so the problem is sometimes I have like a directory with multiple Git repos in it, and I don't know which one of my projects I was doing that thing in. So but yeah, no. I also learned that from there.

0:44:49.939 --> 0:44:57.077
<v B>Yes, wow, super cool. Learn something new every day. Yeah, I should check this out. Rip grep. It's probably like you can just apt get it or something. Yeah.

0:44:57.330 --> 0:44:59.710
<v A>I'm on macOS, so I just Brew installed it. Oh yeah.

0:44:59.912 --> 0:45:00.908
<v B>There you go. Yeah, it looks.

0:45:02.055 --> 0:45:04.654
<v A>Like it says Windows, Linux, and macOS.

0:45:05.380 --> 0:45:12.299
<v B>Support. Yeah, Windows, Linux, Arch Gen2, Fedora, Man. They did everything except Debian. Where are we? Debian. Oh yeah, there you go.

0:45:12.299 --> 0:45:20.044
<v A>Yeah, you can apt get installed. Okay, cool. All right. So Jason's voice gets funny here for a minute. It's because he's downloading. Uh, yeah.

0:45:20.420 --> 0:47:19.600
<v B>That's right. Yeah, if I start doing that weird thing where your voice becomes like really robotic, it's because my internet is totally used up downloading Rip grep. Cool. All right. So we'll jump into the topic. So maybe we should start with like why these things exist, which I think is always kind of a good place to start: object caching systems. So I'll give kind of an example to illustrate why we need something like this. I recently built a replacement for Google Photos. So I built, you know, Jason Gauchy Photos, and I got a—I convinced my wife to install it, and so now her phone crashes like every hour on the hour, and she's not too super thrilled with that. So I'm definitely not recommending it to the audience yet. But the idea is it would periodically scan your phone for new photos, and if you're on Wi-Fi, it'd push them to the cloud. And then I also had an app—have an app where you can go in and very similar to Google Photos, you can kind of see all your photos. So the way the app works and the way the website works is very similar, where um, you know, you need to see the photo, but the photo is in a, you know, protected URL. Um, you know, it's not otherwise anyone could just see all of your photos, right? So you kind of need permission to see that one photo. And um the way this is done under the hood, which is not my creation—this is just how all the companies do it and it's built into a lot of these cloud providers—is with something called a signed URL. So if you ever go to, if you ever go to Facebook or your Google Photos or any of these things where you need to authenticate, um, you know, you can get a, you can look at your photos, let's say in your Facebook timeline, and you can you know go view and tab, and you'll have a URL for that photo of, let's say, you and your family, and you can actually give that URL to somebody else, and even a stranger, and they will.

0:47:19.600 --> 0:49:14.220
<v B>See that photo of you and your family, right? So it seems like a security issue. What's actually happening under the hood is they've generated this signed URL that's kind of temporary. And so that URL works for, you know, maybe five hours or one hour or what have you. So effectively, like, you know, works for your session. Um and then you'll have to go back and ask Facebook server for a new signed URL to see even the same photo. Now the challenge is, you know, signing the URL and doing all of that is really expensive, right? Like, and so if you pull up let's say your Google Photos, you know, they might show you 20 photos or even 50 photos, right off the bat on your screen. All of those are signed URLs—that's 50 signed URLs that Google has to generate. And even when I was testing this by myself on my own photos app, you know, every time I would hit F5, it would have to generate these 50 signed URLs. And getting the URL signed takes like uh, like on the order of maybe tenths of a millisecond or something. So it adds up, right? And so, you know what you want to do is you want to sign a URL for somebody and then you want to cache that result. So if they're just hitting F5 or if they're going to different parts of your page where they're seeing the same images, that you're not signing everything again and again and again. You're not signing the same image. And so that's a perfect use case for an object caching system. So what I ended up doing was when you um ask my photos app for an image—you know, make sure you're authenticating all of that—and then it checks this object cache and says, has this person asked me, you know, for this image before? And if they have, I just return that signed URL. And if I don't see it in my object cache, then I go and I sign the URL. And so that's that's kind of one example, but.

0:49:14.220 --> 0:49:27.533
<v B>But it kind of highlights, you know, it saves you on time, and sometimes, you know, you end up in situations where you really need the cache, but most of the time it's there to really save you on time and resources.

0:49:28.225 --> 0:50:26.730
<v A>Yeah, I think the other thing like you mentioned, not just the expense of computing something but even retrieving something. So the difference between retrieving something off of even a Solid State Disk, although it is closing the gap, but if you are talking about what do they call, like read amplification? So sometimes you want to read something and not only, like Jason's mentioning, you have to do something like compute this cryptographic hash of something to sign it, like very expensive. But sometimes you need to pull in five or six or seven or eight different other resources. So one read amplifies out now all of those reads may happen if you're at enough scale in a data center which are connected by networking switches that cost more than your house, and so they operate, you know, all this fiber stuff like super fancy low latency again. But ultimately, that data has to live somewhere, and your choices are to live in RAM or to live on disk or tape, I guess in some case like a super bad, like long tail case. Yeah, I think.

0:50:26.730 --> 0:50:28.452
<v B>The Glacier and that stuff still uses

0:50:28.806 --> 0:51:36.542
<v A>Some kind of tape, like a robot and tape or something. I don't know. Like that's in one of those horror stories: the guy who gets a ping up on it and, okay, okay, sorry, sorry. Oh no, can get sidetracked. So if you talk about, like cache next to the CPU, you know RAM speed, and then you know hard drive, you're sort of like talking orders of magnitude each one. So when you talk about having something in RAM versus networking speed, you're probably comparable. But when you start talking about hard disk speed versus inter-computer, inter-cluster communication—not inter-cluster communication—then it matters a lot, right? So if you need to do these eight reads, you're reading them all out of RAM, out of computers that can go super fast, versus if you have to go out to the hard disk to get them where you get order of magnitude more storage, maybe, or even maybe a lot more, but also order of magnitude slower. You can't keep doing that, and some of those are going to be fetched more often than others. Or if you know, hey, I'm doing this for user, the chance that you get something else from that same user is increased by this first read, then you may want to bring some of that object into a RAM-resident storage instead of a disk-resident storage. Yeah, that.

0:51:37.082 --> 0:52:16.064
<v B>Makes sense. Another thing too is, and we talked about this at the very beginning of the show, is you know your database might be really expensive, and so you might want to—you know, if someone's just hitting F5, F5, F5 reloading the page all the time, you don't want that to actually, you know, cause your your database costs to go up or cause you to have to buy another database machine and add it to your replica. And so it's often way, way cheaper to spin up an object caching node, an extra node to your object caching system than it is to add a node to your database. Cool. So what are the disadvantages? I mean, we talked

0:52:17.194 --> 0:54:16.439
<v A>A bit about you can kind of already guess that if you're moving stuff into RAM off of disk or moving it closer, you obviously have less capacity. So if you talk about, you know, having a database of like to—to continue Jason's example—if you have a database of every picture off of every user's phone ever, that's not going to fit in as one computer. That's going to fit in many, many, many, many computers. And so if you talked about having only one computer caching, then you know obviously like you can't fit all of that. So you have to be super selective. We talked about a couple of strategies, right? Time sensitive, you know, aggregating data, deducing data, like that kind of stuff to get it smaller and smaller. But ultimately, to get the speed advantage, you really want to limit how much size you have, and normally that's limited to the memory capacity. Now RAM sizes have been going up dramatically recently, so like we have gotten some some advantage there, and with SSDs and stuff, but that's still there. The other thing the object caching tends to do is—I don't want to say garbage or a dump, but like it tends to be just a soup of things. So you are putting all sorts of stuff in the computer to keep it close, but your organization normally isn't as clean as it would be in a full, like relational database. So that means that you're not going to have rich queries where you can do filters and scanning all rows and doing that kind of stuff because it's a disadvantage. But it's also—it makes sense. It's the right tool for the right job. You're already pulling in the results of those complex queries, not doing those queries themselves. Or else you just end up back in the same boat you were to start with. The other thing is if you start storing stuff in memory, you start to have an availability problem, which is if a computer goes down—which even if you have 99.9% reliability—but if you have billions of users, you know, the computer where that user's data is stored could go down. And for persistent transactional databases for things like Jason was mentioned before, like MySQL or PostgreSQL, or

0:54:16.439 --> 0:55:08.948
<v A>You know things that you might hear about with this, there's very intense thought put into how to make sure that no matter exactly what microsecond you glitch or lose power that the database data is sort of consistent and maintained. They don't really do the same thing because that stuff has overhead, it has cost, and no matter how good you do at it, you're sort of risking some amounts of loss. And so most of the time these object cache systems trade off this simplicity for saying, yeah, it might go down if you ask for that key and the key's not present. You just got to handle it. The client has to know, you know, what to do or if it goes missing. And so you have a lot now some things like we're going to talk about like Redis and others do have options for writing out, but they're normally much simpler compared to full RDBMS—relational database management systems—RDB, and that's okay. I just I almost glitched it when

0:55:08.948 --> 0:57:03.209
<v B>I said. Yeah, isn't that weird? It's hard to like figure out one from the other. Yeah, I mean, I think that yeah, you hit that on the head. The persistence in Redis is really for when a machine dies. You want to be able to bring up a replacement machine and move as many of those cache entries as possible so that people don't experience like a hiccup. The purpose of it isn't really for having data that lives forever. And yeah, I mean, you kind of you nailed it. I mean, I think another challenge is anytime you have a cache, you run the risk of the cache becoming out of sync with whatever the underlying database is. So, you know, imagine um you look up what books Patrick's read and um you store that in cache. And then while that cache item is there, Patrick finds another book from Brandon Sorrison that's 2,000 pages and starts reading that one. And then when you go back and say, hey, what books has Patrick read now? I just watched the latest episode. Um you get the old list because it's in cache, right? And so now you have this problem where you either have to delete entries from the cache so that the code that, you know, adds books to Patrick's queue would also have to delete any cache entries, you know involving Patrick, or you just—you just have inconsistency and you just kind of live with that and you kind of make your whatever's using this system be able to handle that. And so you can actually see this in the real world, like I don't know if you've seen this where um you end up with weird situations where like sometimes you buy an item but the item is not gone from your cart in Amazon. This doesn't happen so much anymore, but I saw this happen a couple of times years and years ago, and that's just because, you know, the different machines at Amazon just have different states; they're not in sync all the time. Yeah, and so—so that's that's one of the sort of an extra complexity you have to think about.

0:57:03.546 --> 0:57:29.837
<v A>I went somewhere, you know, talking about that. I did go to some website the other day and it was like, 'We've noticed you have two different carts. Would you like us to merge them?' And I was like, oh, huh, interesting. Okay. And I think it was exactly—exactly what you said, which is that like somehow I was on one machine, then it was in another machine and it somehow like reconciled later that, like, 'Oh, you've added the same thing in two different places. I, you know, I need to resolve this.'

0:57:30.124 --> 0:58:24.660
<v B>Yeah, there's um there's a whole thing we should talk about at some point called—I think it's called CRDTs: Conflict Resolution. I think database table? I don't remember what the T is, but oh, interesting. It's a way to—it's a way to have different machines that are writing to the same source and um the conflicts are resolved, I want to say automatically. I mean, a better way of saying it is the conflicts are resolved through a policy, and that policy sometimes does what you want, sometimes it doesn't, but at least it's like automatic then. So for example, if you use Google Docs and you have a shared doc and you and someone else are typing at the same time, under the hood it's actually a CRDT. But yeah, if you're writing something in Redis or or or or Memcached, then you have to handle all the conflicts manually, and maybe you have a CRDT on top of it that does it for you, but someone has to decide what to do, and those things are out of sync.

0:58:24.660 --> 0:58:34.232
<v A>I was gonna say there's another topic for us as well talking about eventual consistency and transactional and guaranteed and the trade-offs that makes. I think that's been a big space of exploration recently. Yeah, totally.

0:58:34.806 --> 1:00:29.140
<v B>Yeah, maybe we should do—so you know, we actually when we were looking up this show, we found we did a database show, but it was episode 34, which is probably like a decade ago. So um so what we're doing is we're going to probably dive really deep into databases and uh yeah, we should definitely add that to the list, you know, like ACID compliance and all the consistency, you know, guarantees and and the trade-offs there. So under the hood almost all of these object caching systems are key-value stores, right? And so you know, you could use, you know, Berkeley DB or or Amazon's Dynamo, or you know any key-value store—LevelDB, any key-value store would could double as an object caching system. You know under the hood. I mean, Redis might be using LevelDB under the hood; I don't even know, but you know it's effectively a key-value store, but it just gives you a lot of nice things on top of that. So, you know, one of the one of the things it does for you is it supports multi-get or multi-set. So, you know, in the example I gave you, you know a person goes to Jason Gauchy photos which doesn't have a name yet, but but uh um you know they go to this photos thing and they see, you know, 20 photos at once. And so that means, you know, if it's their first time, I need to set 20 signed URLs in in one shot. And if it's not their first time, I want to kind of get 20 or get as many as I as I as there are. And so, you know, in most of these cases, you're not just looking at one cache entry, you know, at a time, and so they they have really nice APIs and also under the hood really nice ways of getting multiple things in parallel, and they make that super fast. Another thing that the object caching does is it lets you set expert expiry times. So as we talked about, we have this cache sync

1:00:29.140 --> 1:02:27.985
<v B>Issue, and so um you know one nice way of dealing with that—or so one sort of hands-free way of dealing with that is just to set an expert expiry time on the cache. Say, look, this cache is relevant for, you know, maybe an hour. And um um you know after the hour, you assume the person logged off Facebook to use the Facebook example and doesn't need that picture anymore. Or um or after an hour, you say, well, has a good chance something's out of sync, and so I'll just throw it out. And and um you know if the person if I'm regenerating this every hour, it's so much better than regenerating every request, right? Maybe you even set it to a minute, and that's still a huge improvement over not having a cache. So um so it's good support for, you know, and they will handle when that minute is up, you know, destroying that item for you. The last bit on how this works is, you know, we can't talk about this without understanding hashing. Now we did a whole show on hashing, so we won't re-rehash it here, but um but but you know you have to as Patrick said, maybe you're making this complicated query to a database to get, you know, all the books that this group of people have read. And um now you need to take that result and cache it, which means you need a way to index it by a key. So you have to take whatever logic went into getting this data the first time and you have to convert it into some unique identifier so that next time if you make the same query, you get the same identifier. And so the best way to do that is with hashing. So you can imagine you could hash the raw SQL query. You could hash a URL in my case that I want to sign, but there's—I think in my case, I actually hashed the user ID, you know, concatenated with the URL because uh I think it mattered which person you were. But um but yeah, you you kind of you know hashing is a huge part of being able to do object caching.

1:02:28.660 --> 1:03:55.240
<v A>So I think the most common one, or at least the first one I heard of—although I think that these first two are probably tied—I'll probably get flack for saying one over the other. Anyways, the first one I heard of was Redis. And when Redis first started out, it was sort of interesting because when it was described to me, it was like, 'Yeah, this is like you know, like a hash map that you just like run on your computer, just like one computer.' Like you just end it up and it just runs a hash map. People can put what they want there and get what they want from it, and it has like a few extra features, but like super simple but like super fast. And at the time, like Jason said when we even first covered database, I hadn't the experience of large-scale systems and all of these complexities. We just described so it's just like that—just seems like a crappier version of a relational database. Like, I too could just write you know a network server that serves up my hash map. Of course, it doubles in the details with adding other data structures and any sort of you know back end or having it split between computers and segmentations and partitions. And okay. Anyways, Redis for sure enjoys a lot of popularity here, adding other features like Pub/Sub so if something is modified, you could subscribe to it and sort of know and you know handle it. Memcached is another big one that's super super popular. In fact, I don't know Jason, do you know which one might be if we had to make a call of which one's more popular?

1:03:56.089 --> 1:03:58.013
<v B>You know, so Memcached is much older. Oh, okay.

1:03:58.334 --> 1:04:00.240
<v A>Then I was—I just heard about them wrong.

1:04:00.240 --> 1:04:48.460
<v B>Yeah, but I think the velocity of Redis is way, way higher. The adoption of Redis, the rate of adoption of Redis is way higher. So I don't know which one's more popular, but—but yeah, there you hit the nail on the head. Those are the two big juggernauts. And one thing you mentioned, which we forgot, which I forgot to talk about earlier, is this is multi-node. So you know, you can have a Redis cluster of hundreds of machines and they're all kind of working together. And when you ask for a key or you store a key, you know, you don't have to think about which machine to put it on or anything like that. And as opposed to like a MySQL cluster where it's mostly done through replication, the Redis cluster is truly distributed where like a lot of the keys only exist in one of the nodes. It's not like a full replication or anything like that. So there's a lot of complexity getting that right.

1:04:50.494 --> 1:04:53.565
<v A>So what? Like an extra 10 lines of code?

1:04:53.565 --> 1:04:59.399
<v B>Just it's a little bit—it's like one line of code more than writing a that extension that scans Swagger.

1:04:59.399 --> 1:05:08.736
<v A>There's a clap back. Oh, a full fully distributed highly available Swagger scanner? Yeah. Other you know key

1:05:10.019 --> 1:05:26.740
<v B>value store systems, uh, you know can work here. So you know Amazon has Dynamo, Google I'm sure has something, Google Cloud has some kind of key-value store. Is it is it called like Big Big No? There's BigQuery, which is the SQL thing.

1:05:26.740 --> 1:06:17.974
<v A>Yeah, I don't—I don't know what the calling here would be. Like you say I mean, I think it's very data store. It's called DataStore. There's a whole like also line of things what we've been talking about is sort of like per user, but there's also huge amounts of work for like Content Delivery Networks—is that the right acronym, CDNs?—and caching. And that's a whole we've not really talked about any of it, but if you sort of take a lot of their problems we've just described, if we talk about like how do you push large volumes, like YouTube? If you want to watch a YouTube video all over the world, you don't want that being served from like a single computer's Redis database. I mean, that's not what happens obviously, but like that doesn't work right. So like you have CDNs and like entire distribution peering agreements and caching data, and like all of these things are just something far outside—I don't even have a ton of experience. They're actually an interesting guest. I'm sure. Yeah. I

1:06:17.974 --> 1:06:24.977
<v B>Was just thinking that we should have someone who really knows CDNs to come on the show. I mean, there's been several companies go

1:06:24.977 --> 1:06:45.025
<v A>public with huge revenues um and in this CDN space and sort of bringing data to closer to the user, closer to the edge. Um which we've overused before, but anyways, uh yeah. I mean, we even talked about those—these aren't really solutions for that, but in my mind like I'm not sure I understand exactly how the two interplay.

1:06:45.430 --> 1:08:22.343
<v B>Yeah, I mean, the thing about CDN. I mean, we talked to—we talked to um that gentleman about doing edge computing. Jackson, we talked to Jackson about edge computing and we talked a little bit about this, but but yeah, I mean, CDNs have to deal with this challenge of you know, 'I have this image, but it's on you know data centers and edge servers all over the world.' You know, which where should I actually get it from for you?' Right? And so that—yeah. That I mean, we should dedicate a whole show to that. Would be super fascinating. Oh, another one to mention is along similar lines is when you're on mobile, you know, you often want to cache things on your phone so that you don't have to go to the internet especially if you're not on Wi-Fi. And so you know that is kind of a whole different level—whole different caching layer because there might be times where like you literally can't get the underlying key. So for example, you know, someone has configured their app to um not use any Wi-Fi or not run on—or sorry, to only run on Wi-Fi, not not fetch anything on metered data. Like imagine a podcast app and so you know they only want the podcast that they've downloaded. So if you don't want to write all of that from scratch, you're saying, 'Oh, have you downloaded it? If so, play it.' Etc. There's a whole bunch of tooling around that as well, like object caching systems for your phone. The one I'm most familiar with is the Firestore, which is um from Firebase, and so I believe that works on Android and iOS, but there's a whole bunch of these systems for for dealing with metered connections and for caching things like that.

1:08:23.052 --> 1:09:03.434
<v A>To go back, I have not for fear, but I want to go back to some of our early episodes and listen. We were talking about this if you haven't heard it yet in the holiday episode or Christmas episode, but like growth as engineers and like decisions we made a long time ago and how they've impacted us. But just thinking through like how I used to view coming out of college databases and then like the richness with which you and I are talking about—not, and I'm by no means an expert; I actually do more embedded work, so databases are far from my day-to-day experience—but just like how much more that great. It's just like one of those things: looking back, you think you know a lot about something, and it turns out you basically know nothing. Yeah.

1:09:03.670 --> 1:09:29.910
<v B>I mean, that's fascinating. I mean, you know the way you described Redis when you first heard about it is exactly what I thought too. And so, you know, when episode 34 went out, our description of Redis probably does not do it justice at all. It'd be fascinating to listen to that. I bet we'd be facepalming the whole time. Maybe we should do that as like a charity thing. If people donate enough to charity, we'll suffer through listening to 'Hold Up,' but we'll do.

1:09:29.910 --> 1:09:33.201
<v A>A Twitch stream of like a live listening to.

1:09:33.201 --> 1:10:13.212
<v B>Ourselves. Yeah, but you know I think you know it's so easy to take for granted things like you have all these keys, each one expires at a different time. You have to handle that. You have 10 different nodes, each one has a tenth of the data. Yeah, and so it's just—it was yeah, we both had like really superficial knowledge of the stuff. I never took actually; they offer database classes at university, but I never took them. I was always taking like all the algebra, linear algebra stuff. So, yeah. I mean, and now in hindsight, you know, at least if you want to build something on web, it's so important to know how all these things work at a more deep level. Yeah.

1:10:14.055 --> 1:11:33.756
<v A>I was listening to—you know talking about like hidden complexity. I was listening to podcasts; I don't even remember which one it was, and it was talking about someone who did not even like true high-frequency trading but just like low-frequency trading on stock markets, and was talking about, you know, like yeah, if you want to just describe it simplistically, like you get the—not the price quotes, but the order book: who has outstanding orders and what is the order flow. And then you just reconcile it over time, and you watch it. He's like, except like you get misquotes constantly, and you have to decide like what's true and what's not true. So like it's this weird thing that, you know, for me, I like go to the internet and like say, 'What is the price of Tesla today?' And you get some number, right? But in reality, that number under the hood there's all these outstanding bids for selling and buying, and they update like many, many, many times a second. And then there's also like all this data error where, you know, like you occasionally get misquotes or things get broken or not quite right, and you have to like also filter all of that out. So like maybe the naive thing you could build in a few hundred lines of code in a few days or whatever depending on your skill and familiarity, but then there's just this huge long tail of complexity that you have to work your way down just to improve it. Yeah.

1:11:34.515 --> 1:12:19.977
<v B>I mean, dude, oh my gosh. I mean, we could spend hours talking about that, but that blows my mind. Like when you say I want to buy something like a share of Tesla, I guess what happens? I'm going to sound dumb here, but I guess what happens is if you say I want to buy a share of Tesla, you know, like Charles Schwab or whatever system you're using pre-populates a price. And my guess is that price is just set high enough that there's a pretty good guarantee that you're going to buy. I mean, I know you can be fancy and say like 'I want this price,' you know, and if I don't get it then I'm not interested or whatever—a limit order, I think it's called, or whatever. Yes? But the interesting thing to me is what number they put there for you. You know, it's like it's like how did they pick that number? They're just.

1:12:19.977 --> 1:12:26.406
<v A>Showing you the last transaction price—so the last price a successful transaction was done at.

1:12:27.250 --> 1:12:37.965
<v B>Oh, so well, but there has to be some amount of signal processing there, right? Because there could be some anomalous transaction, and that would throw everybody off, right?

1:12:37.965 --> 1:13:11.564
<v A>Well, but that's—that's okay. Well, we can't. This is this is yeah, we're gonna take forever. It's literally buried here, so I'm not the right person. We should—we should find a guest. I'm sure some if one of you out there is in the financial industry and wants to talk a bit about the—I don't think we've ever really covered that in depth here. But that's its own thing. I mean, tons of software engineers work this field every day. Get in contact with us, and we'll look for someone on our side as well, but I don't want to get into because I also don't know—that's not my expertise, but I think maybe a bit more than you, but it'll be a whole rat hole, and this will go on for another hour.

1:13:11.564 --> 1:14:04.703
<v B>Yeah. If let's just put the call out there: if you are an engineer or product manager or anybody at a company that does some cool software—so it solves some really interesting problems—you know, reach out to us. I mean, we had we had the gentleman Abhay from Anduril who reached out to us, and it was an amazing show. It's one of my favorite episodes. So you know, if you do something cool out there, you know, reach out to us. And you know, you'll feel comfortable talking to a lot of people. Definitely reach—I mean, I just want to put it out there. I mean, I wish I could sugarcoat it, but you know, you are talking to a lot of people. It does make some folks nervous, but no, I think you know there's a lot of people out there who really would love to listen and hear from your experience. And so if you do stuff in financial, that would be fascinating. If you other stuff, definitely reach out: programmingthrowdown@gmail.com. Wow, that was a.

1:14:05.277 --> 1:14:08.854
<v A>Great segue into finishing off the episode. Well, thanks everyone for listening. Yeah.

1:14:09.968 --> 1:14:25.980
<v B>You know whether you want to be on the show or you just enjoy listening, thank you so much for being on—you know, for hearing us out, and you know have a great 2022. See y'all next time.

1:14:37.592 --> 1:14:39.854
<v A>Music by Eric Barmdoller Programming.

1:14:41.204 --> 1:14:59.340
<v B>throwdown is distributed under a creative commons attribution share alike 2.0 license you're free to share copy distribute transmit the work to remix adapt the work but you must provide attribution uh to uh patrick and i and uh share alike and kind

