About this episodeThis show covers Hadoop, a set of several languages and libraries for working with big data. Tools of the show: Emacs and Chrome Browser…
This show covers Hadoop, a set of several languages and libraries for working with big data. Tools of the show: Emacs and Chrome Browser Sync. Books of the show: Hadoop: The Definitive Guide http://tinyurl.com/cp3mw32 and Anathem http://tinyurl.com/cas8bux
★ Support this podcast on Patreon ★Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
Hadoop
Oh, yeah. No. Never mind. Your mom? This sounds like we're making bad mom jokes, but I'm not really. Yeah. I think I just dissed my own mom. Anyway. Aww. So Marco Aurelio sent in a question, and he's looking at doing some C#/.NET coding for a website that he's interested in making. And he was sort of interested. His question was, you know, he knows that, like, you know, server-side stuff, you know, the code and the CPU is used on the server. And so if you have, you know, one user, you're using some amount of CPU. If you have 1,000 users, you're using, you know, maybe not 1,000 times, but the CPU scales up, right? So his question is, how can big websites, like, is it true that big websites like eBay and Amazon and things like that, you know, run things on the server side? And how do they do that? And how did the server not explode? And then along those lines, like, what languages should he focus on learning?
Yeah. So, I mean, it sounds like he had a question there. He has an idea. Yeah. So his idea was to kind of build a website, but he's worried about it scaling what technology he's going to choose. Yeah, totally. So I have a slightly different answer. And mine is that I think sometimes in the tech community and as engineers, you know, you over-engineer things. So this is a classical problem. And so having the issue where you can't scale your website because you're growing too fast would be, like, a very good problem to have. I mean, there are certain things you don't want to do to aggravate it or especially if you get to the point where somebody is funding you or you're making a lot of money and your website goes down and people are depending on you, that's a really bad problem. Right? But when you just have an idea, it is more important to get the idea out there, to start working on it, to find other issues like, okay, people, I need to shift this idea slightly or I need to do this. Then just spend tons and tons of money trying, you know, like if you ever read about some of these people that started like Google, you know, it was two guys and some university equipment or, you know, Mark Zuckerberg at Facebook. You know, it was just like running in his dorm room off his computer, right? Like, I mean, none of these things started with, like, 'I'm going to start with 10,000 computers and I'm going to serve millions of,' I mean, that's how you go bankrupt, right?
Did you know? So sorry to interject, but Stack Overflow, the website that has, you know, many questions and answers for programmers, it actually started with the two founders answering all the questions themselves. Nice. Yeah, isn't that crazy? So they just, and I don't even, I think they were talking about it, they didn't even have a website. Right? Like they had this form where you'd click submit and then they would create a .html file with your
Right. Yeah. And I mean, I think even you take that example, right? So there's an idea and you can read a lot about this. A lot has been written, and this isn't exactly an entrepreneurial show. I don't think I said that correctly. I think it's pretty entrepreneurial. But okay. We're kind of... Okay. All right. All right. But minimally viable product. That's kind of like a word, right? So the idea there is, in fact, don't even make a backend to Jason's example here of Stack Overflow, whether it be urban legend or true. The internet shall tell away us. But, you know, if you just make a front end that looks like what the website would, people can kind of try it out and test it. You can get a ton of feedback and save yourself days, months, years of development time. So that's kind of where to start. And then, you know, from there, you can kind of... Jason will kind of address like how does that work? Like how does one serve millions of users a second? An hour? A day? Millions of users a day. Let's go with there. So,
Yeah. I mean, but to Patrick's point, just to wrap that up, you know, even when I was making Trivipedia—that trivia, Wikipedia thing—I started off with just having a flat file and you just scan through that file for everything. So if I needed to find a user by the name, I had to search through the whole file of like thousands of users or hundreds of users to find that one. There's no index.
That's the thing. So it grew to where, let's say, I think now there are what, like 2,000 monthly active users. And so let's say there are 100,000 users in the system. So I couldn't do that anymore. Like I couldn't just scan through all the usernames. And so I had to—I ended up making ZombieDB, which is open source. And I think I posted on the podcast on G+, on the podcast page about that. But so I had to actually make a database. But that came months later, right? And if Trivipedia, if no one was interested in it, then I would have saved myself the trouble of having to make that database, right? And I probably saved myself the trouble of doing other things which I would have done if there were millions of users, right? So, yeah, to Patrick's point, you totally want to start small. Don't worry too much about your server blowing up or anything like that. But now let's answer the question from a tech standpoint. Like, how does this work, right? Like, do all these guys like Amazon and Google and eBay, do they all just write JavaScript, or do they, you know, do stuff on the server? So they do things on the server, and it works through a process called sharding. And Patrick already helped me out here, but I'm going to take a first crack at it. Typically, you'll go to, let's say, Amazon.com. What will happen is that will go to a front-end server. So this server will get your request, and there are several front-end servers all around the globe. So you'll go to the front-end server that's closest to you. So it'll take your request and it'll say, okay, what servers are pretty, you know, lightly loaded? And the servers themselves—the back-ends—are constantly telling the front-end, 'Hey, you know, I'm not busy.' Or, 'Hey, I'm slammed processing people's orders,' right? So the front-end server will look for a server that's not busy and then redirect you to that server. So then your request will go through to that server, which will do all the things like query the database, see if you're logged in, do all that stuff. And keep in mind the database itself is on another server.
Yeah, set of servers. And so there's this other process going on where the database has a front-end, which, you know, keeps the load pretty balanced among all those database servers. And so this process of having all of these machines sort of working together and having the least-used machine, you know, handling your request, is what keeps websites like Amazon and eBay up and running. And a big part of doing this isn't, you know, what we're going to talk about on this show, Hadoop; it's more for, like, batch processing. It's not things that you're going to do, you know, in real time when you're accepting a web request. But just a big part of doing anything on the web or with Big Data involves sort of managing many different machines and routing work to one machine or the other. That's right. Yep.
And so, I mean, yeah, and I think there exists server back-end technology for many of the most common languages for people to write in. I mean, there's even Node.js, so you can write JavaScript on the back-end and use that as a server. You know, you can—just like all the major, I mean, Java, C++, I would assume C# as well. I mean, there are all these things have back-end pieces that you can write to. There's middleware kind of stuff, let's call it, that handles this load balancing and splitting. And then you write your server and your language on the back. So it's—I mean, it's slightly more than what language to use. It's kind of like understanding this underlying and the problem. But you don't really know where the scaling problem is going to happen until you really are kind of almost done, right? So something like, if you think about, like, a slash dot—let's take Slashdot, right? So they have news stories which are being displayed. But their bottlenecks are going to be very different than a site like eBay, which is handling transactions and counting down auctions. Or Amazon, which has to handle, you know, when something sells out and they have no more and they don't want to oversell something, right? These things are—there's amounts of traffic, there's hits on data. I mean, those things are going to have different bottlenecks at different amounts along the growth curve of users, and, you know, on how many transactions are being handled, and that kind of stuff. So, I mean, you really kind of, if you solve it too early, you risk solving the wrong problem.
So, all right, well, on to our news. News. I have the first one. All right. Okay. Yeah. So I'm doing the first one. I saw an article linked today on Hacker News. This is interesting about the Fast Fourier Transform. So this is real. This is kind of like a FYI. It's not exactly news. It's not something updated, but it was a pretty good article. I kind of enjoyed reading it. So I have a little bit of background with what the Fourier transform is. So without getting into the deep math. And it's like this guy does a good job of explaining it thoroughly. But if you just kind of skim read it, you know, you can also kind of get the gist. So Fourier Transform. Oh, and
Yes. And he even posts like more detail. This website is actually very interesting. We'll have to take a look at more and see if there are any other articles. It'd be really interesting to you guys. Or you guys just take a look and figure it out on your own. But he covers a wide range of topics. But a Fourier Transform in brief is going from the time domain to the frequency domain. So if you have some data that over time changes. So the example he uses is audio recording. So you have digital samples over time, and you're interested to say what are the most common or most prominent frequencies in that sound clip. Then you want to transform from that time data to frequency data, which says, you know, at 80 kilohertz. I don't know if that's too high. I'm not good with my audio.
Know. So, okay. Some number of Hertz. You know, this is the peak signal. So like, oh, okay. You know, maybe it gives you some information or you want to do some sort of mutation of the signal and then transpose it back. But this is something that's very common. You'll come across a lot in a large amount of domains: image processing, audio processing. I mean, even stuff that seems completely unrelated, it can come up. But yeah.
And this article talks about a specific kind of version of that: the Fast Fourier Transform, and also the discretized, discrete version of that. So going from math to kind of practical there, and a lot of the implications. So it's a pretty good treatment. So if you've ever heard of that and wondered what it was or trying to learn more about it, I would definitely check out this article. It seemed like a pretty good description. Yeah.
Oh, no. That's that guy who crashes through the window. The Kool-Aid Man? Yeah, the Kool-Aid Man. The Kool-Aid Man's coming out with a console. What? Pretty awesome. Yeah. Hopefully it's like bullshit. And you could pour. Anyways, so the Oya is coming out. I'm pretty excited about it. I haven't ordered one because Patrick has scared me off of Kickstarter, but I'm super interested in Oya. I still might order one off their website even though the Kickstarter is finished. So is it available for ordering off their website? Yeah. You
the same price? A little bit more? I'll find out. Oh, it's okay. But basically you can order on the website. It comes, I think, in March or April. But it is a—for people who missed the episode on the Oya, it is a, I guess I'd describe it as an Android-powered console. So it's a console with a controller and all this good stuff. But it's totally Android. So any existing Android games you can play using the touchpad on the controller, and any new Android games will be able to support the hardware buttons of the Oya. And it's pretty awesome because we've never had this.
or PS3 or something. We've never had an open system. So a little bit of history on consoles. The way the PlayStation and Nintendo, you know, Wii and Xbox, the way these things work is, well, unless you're Nintendo and you're awesome. But let's talk about everybody besides Nintendo. The way these work is you lose money on the console. So like every time you buy a PlayStation, Sony loses money on that.
Right. Yes. So they actually make money by charging developers for a dev kit. So, for example, if you want to make a PlayStation 3 game, then you buy this dev kit. And the dev kit has a little bit of hardware, but I don't even know if they have hardware nowadays. It's probably all in software or firmware. But they'll send you probably a PS3 with some special firmware. But they'll charge you for the dev kit—I think it's like $200,000 for a dev kit. And the only reason why the price is so high is so that they can recoup some of the money. And the idea is people who buy your game are going to give you money, and you're going to give some of that money, pass it along to the hardware manufacturer.
Well, I mean, so it's worse than that, right? So, I mean, it's that for every copy sold, they have to—they put DRM on the game. So if you don't have—but I guess this is kind of almost slightly different than normal DRM, which is that if I have owned media, but that media is not signed by Nintendo, I can't play my media on the Nintendo device.
So you have to go to Nintendo and they—I'm doing air quotes here. They test your software to make sure it's not going to break the console or isn't a virus or anyone—it doesn't crash. It's good, right? And then basically with their permission, then you can turn around and you're allowed to sell that game. But you owe them X percent or dollar amount. Oh, that's true. Per everything that you sign. Yeah, that's the most—I believe that's like a very common way.
Yeah, I think there's an initial like $100,000 or $200,000 investment just to keep like the small people out of the market. And then there's also a rev share. So this is talking to a friend of mine who works for EA like a long time ago. So it might be different now. But yeah, so the point of it is, you know, Patrick and I can't make a game for the PlayStation 3, right? I mean we just don't like have those resources at hand, right? So you have to be a big publisher. Or Nintendo has to come to you. Like World of Goo is a common example where they're a really popular indie game. And they do really well in Flash. And I think they were out on mobile even before the Wii. And then Nintendo contacted them and some agreement was arranged, et cetera. The thing about the OUYA is it's a completely open platform. So like any game that anybody puts out for Android, like Trivipedia, you could play it on the OUYA. Like any Android program out there will run. And so it really just sort of opens up the game console experience to like to the whole world of developers. And that's what's really exciting to me.
And the general trend has been that along those lines, right? So like even the Xbox, there's like was it Xbox Live Arcade? Yeah. Okay. Maybe I'm butchering. I think PlayStation has something similar. And Wii U has something similar. And even maybe the Wii did, right? So the main games that you go to, you know, Toys R Us or Target or Best Buy or I don't know where everybody goes these days. Because whatever in your country the local equivalent is to buy a game, right? There's those, which is kind of what we're talking about. But then there's these others. But those still have limitations. Like I remember reading something about when Minecraft came out for the Xbox, right? So they had some people doing this. And then they had an update. And then it was like, oh, if they wanted to update like a patch again, you're supposed to go through all this testing again. But that testing costs money. So like it's like a thing like you can't—they wanted to just push it early and push it often. But that didn't—like that was not compatible with how the money was set up. And so it caused kind of a problem.
And the other problem too is although there is an Xbox Live Arcade, there isn't a developer—there's a developer ecosystem, but not to the extent of these open platforms. Could be, yeah. Yeah, like for example, we talked on last show with that Cocos 2DX, which is it's not a game. It's just a library that you can use to make games. Well, for you to do that on an Xbox Live Arcade, I'm assuming you would have to be able to like publish like the library. I'm not quite sure how that would work. But on an open platform, you just give all the source code. And the person can take your source code and link in the Android libraries. And it just kind of works. So the ecosystem is much more healthy on Android.
And so this is a very positive development, right? So like Ouya is on track. They started shipping the developer consoles, which are very similar to the regular consoles but already kind of like opened up so the developers can do what they need to do—run unsigned code, that kind of stuff. And so this is a positive Kickstarter story. Yay, Kickstarter. So hopefully they'll stay on track. And early next year we'll be talking about the reviews of Jason's Ouya console.
—Future of the Web. The future of the Web would be HTML8. Oh, no, no. Man. Holy cow. Maybe that's far in the future. HTML5? Yeah, at this rate, that's like the year 3000. It's finalized. You know, this is one of those—I mean, it's kind of interesting just to talk about that. I think it's kind of slow, these—ratification of these things. Like, we've already kind of entered the HTML5 zone in my mind, like it's generally used, right? But yet only just now did everybody kind of agree on what that meant to some extent. Yeah. Which still doesn't really mean anything because—all sorts of reasons. But you hear this, like, remember when wireless Wi-Fi N, 802. 11n was coming out, right? It was draft N. You could buy draft N routers. Oh, yeah. I remember that. Draft N routers weren't guaranteed to be compatible with N. And then, like, a year or two later, right? Then it was like, oh, now you can get the actual N ones. Yeah. I mean, or I remember too, like, C++, right, even, that went through this whole thing about, oh, we're going to come up with a new C++ OX. Oh, that took so long. And it took over 10 years, and then it was, like, finally C++11 or whatever. It's hilarious. So, I mean, it just—sometimes we forget that, like, the world moves on past these standards bodies, but the standards bodies do play an important role in kind of saying, like, this is, you know, what HTML5 really is and really contains. But even then, it's not done. Like, they still have other work to do to kind of make sure everything's okay. It's not like—finalized doesn't mean, like, it's done. It means, like, oh, now we can move to testing and compatibility and, you know, actually making it an official, like, HTML5 thing.
Yeah, it's really just almost like a social or political thing. It's basically, you know, like, let's say everyone complains about Internet Explorer, right? Especially older versions of Internet Explorer. Like, Internet Explorer 5 doesn't do what, you know, Firefox and Chrome of the same era do, or maybe 5 is too old. But you see what I'm going with this. So this is their way of saying, you know, HTML5 is real. You can make content for it. And if someone doesn't support it, that's on them, you know. And so it's like a political thing to motivate people to switch. And I'm pretty sure if you're using an old browser and you go to a website nowadays that has HTML5 content, they'll actually have a little link saying, 'Hey, you know, your browser is super old. You can't display this website correctly,' and, you know, and you should go get a new browser.' Whereas, you know, before the specification was complete, they would just try and make it support everything.
Yeah, and I mean, we should say also this is by the W3C Foundation or W3C Consort—I don't know what the C there is. It's Consortium. Oh, Consortium. Okay, thank you for saving me. No worries. The World Wide Web Consortium. Yes, okay. And, you know, it is a good thing. It is, you know, that they've finalized it. And also, they've taken time to announce that they've begun the draft of HTML5.1.
Woo! Oh, man. So, did they keep the peer-to-peer? HTML5 was supposed to have peer-to-peer support. But, like, no browsers had actually implemented it to this day. But, I mean, so basically what that means is you could have a BitTorrent client totally written in HTML. Like, you just go to a website and you just start torrenting, like, on, like, the site. You know, it's just craziness. And I know I read an article where they said, 'You know, no browser will ever support this.'
Yeah, totally. All right. So, I think you're up next. Tell me about some sweet desserts. Some sweet desserts? Well, I've just been eating some raspberry pie. Oh! Yes. Been eating from the Raspberry Pie store. You bought raspberry pie at the store? I did. It was delicious. Yeah, it was one of those Safeway specials. But you have to have the card where they harass you, you know, the Safeway Club Card. So, like, now it's like every time I go, they want me to buy another raspberry pie. I'm like, 'No! No, you people!' So, Patrick is like, God. So, okay, so Raspberry Pie store has just launched what, today? Or a couple of days ago? But it's pretty cool. The idea is if you own a Raspberry Pi device, you can go to this store, you can download apps. Assuming you somehow transfer them to the device—maybe you download them with the device itself. And then you can just start using them. So, they have a number of free apps. There's Free Civ, the Civilization clone. Some other free and open-source games that seem to be ubiquitous. Like, Battle of Wesnoth seems to be on every possible thing. Like, I have Battle of Wesnoth on my Gumstick, my phone, my, like, three computers. So, a lot of these open-source games, it's just as soon as something new comes out, they try and get themselves on there. But there's a number of awesome things that you can install. Some are free, some cost money. But if you have a Raspberry Pi or if you're thinking of getting one, definitely check out store.raspberrypi.com and see what's available.
Who's going to? So, this is kind of. So, my parents, ever since I was maybe, like, seven, they've always just asked me what I want for Christmas. Because they just, they don't know anything about, like, computers and things like that. So, as tradition holds, my mom asked me what I wanted for Christmas.
link. Yeah, yeah. Okay. I had to give her a tiny URL. Cool. Cool. But, yeah. So, my coworker said, well, you know, if you get this, then you're stuck with Android. You should get a, you know, Raspberry Pi or a BeagleBoard or something. And that is kind of true. Like, if you get Raspberry Pi, then you have just a pure Linux shell with, you know, you could sudo app. You can install packages. You can do whatever you want. If you have Android, then you're stuck in the Android ecosystem. And so, I haven't yet decided which route I'm going to go. You already sent the link, dude. I haven't sent it yet. Oh. Oh, it's sitting in my, like, saved messages but not sent, you know, in Gmail. So, yeah, I'm holding on.
This is Tool of the Show. Show, show, show, show, show. So, my Tool of the Show. Show, show, show. This is like the tool that I use more than anything. Like more hours of my day are spent using this tool than probably any other program or anything. Sledgehammer. That's a... Measuring tape. It's called Shoes. No. So, my Tool of the Show is Emacs. And Emacs is a text editor. Text editor. Or sorry, Emacs is a text editor. Web editor. I don't know where I was going with that. Text editor. But it is so much more than that. It has a ton of features, a ton of macros. You can have like 20 files open in the editor at the same time. 20? Well, you can have infinity files open at the same time. And you can do things like find all occurrences of Patrick and change it to gives Jason a hard time in all 20 files. Like you could just type escape and then find replace all files or whatever. So, it has a bunch of little macro support. And it has all these cool tricks. It has a color theme picker. You
And just a bunch of cool macros. There's an Emacs wiki, which has a ton of things to make your life easier. Like, for example, like just a short anecdote. You might have something like a file which has a number: colon, and then some text. And you just want the text after the colon. Like you just want to get rid of the number and the colon, right? So, like if you're just using Notepad, you'd have to do this by hand, line by line, right? But in Emacs, you just
Yeah, you could write like a shell script to like, you know, cap the file, go through set and oct and things like that. But in Emacs, you actually do like a regular expression replace, like almost trivially. Or you could use something that had a column editor. A column editor? But what if it's like the colon moved a column because there's too many digits? Oh,
Come on, man. Where are you going with this? They're trying to make us lose our clean rating. I guess it's still clean, but not like... What editors are you on, Patrick? I don't edit my code, man. I just think it. Oh, man. You write in binary? I just have telepathy with the computer. Oh, it's pretty... Do you have
But you have to train. I mean, almost all of them have always shown, like, you have to go through a set of, like, exercises. Oh, yeah. Like the old Dragon dictionary thing where you'd have to, like, it would translate the words you spoke or whatever or write them down. You'd have to read, like, a chapter of Shakespeare to an act of Shakespeare to, like, train it. So that was the same thing. Like, you need to go through some thing to train it, at least now.
okay. So I dodged your question. But I happen to actually be in that weird camp of nerds who thinks IDE is, like, an amazing invention of modern times where I can have 20 files open. I can have colors. And I don't need these crazy things called, like, these crazy escape key combination macro. That's my camp. So, yeah. But I do appreciate that sometimes you have to open up a shell and you have to do stuff there. Or you're SSH'd into a computer. Yes, I understand. But that's, like, a thing of last resort. Yes. Okay.
Yeah. Emacs or whatever. I mean, that's not an actual phrase. I just couldn't think of one. But like, you know, like, oh, I only use VI for everything. Or like, oh, I only use what's the, there's like a cult of something. I don't know. All these things, right? Like, oh, I only use Emacs. And I'm sure there are people who do. And I'm sure that's what you're doing. But I really feel like most people, it's not really true. Like, same thing as like, I remember there's all these people talk to like, oh, Linux this, Linux that. And it's like, what do you run at home? Like, oh, Windows. Yeah, right. It's like, I don't have a problem with that. Just like, own up. Like, if somebody makes something good, it's good. Like, don't, you don't have to like, oh, it's made by Microsoft. It must be terrible. Yeah. Like, oh, come on. I mean, if it's good, it's good. There is
A lot of people hate like the iPhone and the iPad. Like, oh, they're terrible, right? And it's like in reality like, okay, fine. You might think that. But I think most people just, it's, oh, it's because it's Apple. It doesn't matter if like, you could provably show that it was the best thing. Like, people would still like, oh, it's Apple. It can't be good. And then vice versa, too. Other people were like, oh, if it's not made by Apple, it's got to be terrible. So I think nerds like for some reason or geeks like really fall into this trap of like, like, we say we want to be open-minded. We want people to accept our thing. But it's like in reality, we try
to like, ah. I think everyone is, though. Even like, you could be, I had a friend growing up who was really into skateboarding. And he was always like, oh, you have a Veriflex. That's a piece of crap just because it's a Veriflex. You know what I mean? So I think everybody who's like, really into something has this like, brand loyalty. But, yeah. So the thing about tech, though, is tech is very functional. So, like, to have brand loyalty for something that doesn't necessarily have a style or the style doesn't matter. Like, it's one thing to be like, I really like, you know, Express jeans. And it's like, you do it knowing that they're not going to like, make you walk faster, you know? But it's like, oh, I really like Emacs. And then for Fidoists to make the argument, like, Emacs makes me a better coder, which I don't believe. Then now you're putting, you know, you're putting like, you're turning something that is like, a style, like, a personal preference into, like, oh, I'm functionally like, a better programmer.
Well, but even if people say like, oh, I'm more productive using Emacs than an IDE. But their problem is like, okay, well, like, you know, did you try all the IDEs? Well, no. Did you try one? Did you stick with it long enough? And if you kind of dig, it's like a lot of times like, well, you know, I tried it for like, a week and I just couldn't stand it. Well, I mean, did you like, pick up Emacs and start using it hyper-productively within a week? No. Yeah, exactly. Like, I mean, I doubt it, right? Maybe if you're like, some savant. I don't know. Maybe. But like, no. Okay, anyways, my tool of the week is Chrome Browser Sync. It's pretty awesome. It's not really like a tool of the week. It's totally a tool to win. I totally copped out on all these. It's okay. So, I really
All right. Anyways, so Chrome Browser Sync, if you don't know, Chrome is a browser made by Google. Yep. And one feature that I've been using Chrome, and I like it. I mean, but I like Chrome. And one feature that I've decided I really like is across my devices that if you have Chrome and you sign into it, which, I mean, we can get to all the debate, but all right, whatever. So you sign into it, and it'll synchronize your bookmarks. It'll synchronize. You can see what tabs are open from your other computers. And that's like a really good feature. And I think now, somebody's pointing out either Firefox ships it, like, by default or it's an add-on or something. I don't remember. But that Browser Sync functionality in whatever browser. I happen to use Chrome, so that's my tool of the week. But they may all have it by now. Yeah, Browser Sync is.
tab. You know, bring it open. It's amazing. Like, especially, I notice it a lot when I'm using directions. Like, I'll be at home, and I'll look up directions for a place. And then I don't want to, like, I mean, it's not a big deal to retype in the address, but it's so much easier to just pull up your phone and say, 'Show me my desktop tabs,' and the directions are there, like, done, ready to go.
Okay. And Anathema by Neil Stephenson. Sorry, guys. And it's a really long book. I don't—I think it's like bordering on like 1,000 pages or something. Oh, wow. So here, the paperback is 981 pages. Wow. So it's really long, but it's really good. So this is going to sound like, Patrick, why is this the best book? You have to stick it out through the first couple hundred pages. First couple hundred pages are a little bit rough, but it is worth it. It's like a huge investment, but like when you make the investment of like, oh, okay, what's going on here? It's really—I don't want to do any spoilers about what the—so further part of the story. But it starts off and you're in a monastery. And it just starts describing like a whole world, which is like slightly different than ours. And like you kind of begin to pick up that there's some things which are different, but kind of the same. And it just like really—Neil Stephenson just goes into like great detail about like all the functioning of this monastery. And it's not—lest you be confused—it's not like a religious monastery like you would think of today or in kind of our world. So you kind of got to stick with it and see it's something slightly different. Again, I'm trying not to give away because some people really want to have all that surprise of the book. So I don't want to give more than even the back cover would say. But check it out. It's really good. And like I said, you got to stick it out for the first little bit. Yeah, it
Well, it's definitely not Anathem. No. Because that's missing an A. So my book is Hadoop: The Definitive Guide. And I've actually been reading this book for a while now, trying to sort of understand more of the like Hadoop internals and the way like Hadoop sorts of does different things on the back end. So as somebody who—like I feel like I can call myself a MapReduce expert. Like I might get destroyed for that by somebody who's like a crazy expert. But I know a ton about MapReduce. I work a lot with like MapReduce and Hadoop internals and things like that. So you just
Yeah, I know. Bring it on. I feel like I can take it. I accept the challenge. All right. Unless we get like Jeff Dean or Sanjay Ghemawat, the original creators of MapReduce, unless they comment. That would be awesome. Yeah, actually I could take abuse from them. I'd be worth it. Yeah. So you guys, that
Oh, yeah. We should see. They're in the Bay Area somewhere. Okay. Yeah. All right. So this book, even as somebody who does a lot of MapReduce and Hadoop, the book is incredibly useful. It's a great reference. It has a lot of examples. It really quickly answers the question, 'Why do you use Hadoop?' which we'll hopefully answer ourselves.
Okay. Well, it ends in OOP. Is it a poop joke? Yes, it is a poop joke. Okay. Now I'm getting a different kind of stare. It's like despondence. Okay. So, let's give some history on Hadoop. Hadoop was based on MapReduce, which was something created by—I was going to mention Jeff Dean and Sanjay Gemawat at Google. So, they created something called MapReduce. They wrote out a paper explaining how MapReduce works. And then Doug Cutting, who is another engineer somewhere in the Bay Area. I think he made a startup. Is that right? Like,
Right. He began working on it. And then at some point, Yahoo either bought his team or he joined Yahoo. That was sometime around 2006-ish. And so, then he kept working on it while he was at Yahoo. So, he actually—the whole reason why he created Hadoop was because he wanted to support Lucene, which is an open source reverse index. And we actually talked about Lucene in the Mailbag episode of this show, answering the question posed by the person who wanted to create his own, like, he wanted to index the web for Magic: The Gathering. So, yeah, Lucene is a reverse index meant for indexing thousands, millions of pages. And Hadoop was something that Doug wrote to support that. So, at the time, it was kind of meant for that and it was sort of myopic. But since then, it's grown to an amazingly large scale. How big? The last—the largest Hadoop file system that we know of is run by Facebook, and it is 100 petabytes. Do you know how much a petabyte is? More than a terabyte. How much more than a terabyte? A hundred. A thousand. Ten thousand. That reminded me of that Monty Python where he's like, blue—I mean yellow. No. So, yes, a petabyte is a thousand terabytes. So, all you guys who have like a terabyte hard drive at home, so a thousand of those, that's what... No, a hundred thousand of them. Well, yeah, you're right. It has to be more than that. A hundred thousand petabytes.
Yeah, yeah, it's true. It's true. Okay, so you want to discuss some of the features? What are the things that... So, you know, one thing we should mention in the beginning is Hadoop has become almost like an umbrella term. So, Hadoop is the MapReduce for sort of for doing this distributed processing. But people also refer to Hadoop as this collection of tools with Hadoop being one of the things in Hadoop, which is really confusing. Let's talk about some of the other features, some of the other tools that come with Hadoop.
MapReduce. Yeah, that's a good point. So, first of all, let's do a little bit about distributed computing. Back in the day, people used to do... Well, and they still do, but people used to be totally consumed with MPI and things like that. MPI stands for Message Passing Interface. And so, if you had a lot of data and you wanted to do something with that data, you would break the data up into pieces, then you would pass each piece to a different computer, and then the computers would probably, like, send you back some results, and you would put the results together. And then if you sent... If you passed a message to a computer and it died, your whole process would blow up.
Yeah, or you had to say, oh, this machine died, so I need to, like, pass the message to somebody else. And so, you had to be completely consumed with all of these, like, meta things that didn't really matter to solving what you wanted to solve, right? So, it turns out that not every problem can be what's called embarrassingly parallel, where you just send chunks of data to different machines. But almost all algorithms can be implemented using something called MapReduce. MapReduce. And so, the idea is you have... You take your data, you break it up into chunks, then for each chunk, you execute a map on the chunk, which takes this chunk of data. It could be a sentence on a web page, or it could be a URL, or it could be, you know, any, you know, atom of data, and then returns a key value pair. So, for example, let's say you wanted to count the... You wanted for every word on the internet to figure out how many times that word is there. So, your map could take a page of the internet, and it could scan through that page, and then spit out a bunch of key-value pairs, where the key is the word, and the value is the number of times you saw it on that page. So, if you saw, like, 'the fox jumped over the dog,' then there's two 'thes.' So, one of your key-value pairs would be 'the,' comma 2. Another one would be 'fox,' comma 1, etc. So, now, all of these key-value pairs generated by all these mappers, they're all kind of floating somewhere in your cluster. So, you have something called a shuffle that takes all of the keys that are in common, and all the key-value pairs that have the same key, and squishes them together. So, if you have ten websites with 'fox' as the key, you'll just have one key with 'fox,' and then instead of a value, now you'll have a list of values, where that list is how many times fox was seen on all these websites. Then you have... That's the shuffle phase. Then you have the reduce phase, where you collapse that key list of values down to one answer. So, in this example, you would take 'fox' and then 2-1-2-1-2-3-2-4, and you would add up all those numbers together, and you would say, for fox, for the whole internet, it's whatever, 13 million, or something like that. And the cool thing about this is that all these pieces can happen in parallel. Like, the part that collapses all of the 'fox' values and the part that collapses all the 'bear' values could happen on two different machines, and the part that scans website A and scans website B can happen on two different machines. And it all just kind of works. And so, as long as you're... And the MapReduce code also handles all these things like, oh, the machine that was processing 'fox' dies, we need to send 'fox' to another machine. They've dealt with all that for you, so you don't have to do it. So, that's a short summary of MapReduce. And Hadoop is an open-source version of this.
All right. Yeah. So, I mean, part of this is going to be if you're going to... You kind of started with something that was a little bit presumptuous, dare I say, which is you start with everybody reading all the tasks, reading one page of the internet. Where do you store something that's every page of the internet? You can't just store that on an NTFS or EXT file partition. It's so big. Yeah. Well, not only the size is large, but the number of files is ridiculous. Oh, yeah. Right. So, you could run into problems. So, I mean, one thing that has to go along with this is you have to have a distributed file system. So, first of all, you can't house all the data on one computer. Right? But then on top of that, even like how you would access it in a way that is efficient so that you can have these tens, hundreds, thousands, millions of map threads working on this. You need a way to be able to retrieve that quickly and reliably and in a sharded manner so that, you know, that can take place very quickly. And they've handled that as well with the Hadoop file system.
Yep. Totally. Yep. So, the Hadoop file system operates in 64 megabyte chunks. And that chunk could have one file in it. It could have a piece of a file. It could have 10,000 files in it if the files are very small. And so, versus, you know, a regular file system which uses, you know, B-trees and Red-Black trees and things like that, this uses something totally different that's meant for, you know, gigantic files, millions of tiny files, all of these things. And it expects you to access the files using something like Hadoop versus, you know, a file system which doesn't really know how you're going to access the files. Yeah. Yep. There's also HBase. HBase is a column-oriented database written in Hadoop. So, you know, whereas HDFS is a file system, HBase is a database. So, if you need to, you know, get rows by key and if you need to find all keys where the first name is this, if you need to do all the secondary indices, all that stuff, but you still need the distributed coolness from HDFS, which HBase is built on, then you can use HBase and get that.
Yeah. Yep. So, all this code that's running, I mean, if we begin to talk about hundreds, thousands of servers or even more—I don't know how high you could go, how high do you want to go, I guess. You're going to have to wait to keep that. So, machines are going to die. If you talk about that many machines and some of this data can take a long time to process, I mean, machines are going to die. You might want to add new machines. You want to increase your capacity. I mean, that would be a huge mess in the olden days. I mean,
with that, right? I mean, it would take you months to have to deal with the, oh, this machine died, so I'm going to send it to that machine, right? I mean, that could be such a nightmare, right? Or what if the machine that's sending the things dies? I mean, you don't want to have to restart the whole thing just because of that. So, dealing with that, right? That could be a nightmare. And so, Hadoop's thing, which handles that, is called Zookeeper, going along the lines of pet animals and things like that. And so, yeah, Zookeeper is a distributed coordination service. And so, really short, what that means is somebody can write some data to Zookeeper, and somebody else, if they try to write data and the data collides, Zookeeper sort of figures all that out. So, if two machines both want to take the same job at the same time, Zookeeper says, 'No, look, only one of you guys get this job,' things like that.
So, like we said, I mean, Hadoop is kind of, when people talk about, they're kind of talking about all these kind of tools, which are kind of all necessary to get together and enable you to be able to run those MapReduces. And so, I mean, kind of now, talking about the strengths, one of the things that we talked about is you bring up more computers, great. You can have more threads, and the threads can run sooner. They don't have to be serialized. And so, I mean, really, you can just scale this dot, dot, dot. Yeah, totally. Whatever. Like, however much, I guess, time or money you have determines, you know, how big you can go or you need to go or have to go.
Right. So, they have a version that they've altered, I guess, or changed. Or just not Web Services. Elastic MapReduce or whatever, right? Yeah, right. Which is very similar, yeah. So, they have their version, which runs on their infrastructure. So, they have, so, like, you know, for instance, they may not, I don't, I think the way it works, I'm speaking a little out of my expertise here. But, you know, instead of having, like, a Hadoop file system, they have their version of the same thing, right? Their Elastic file storage, which they kind of hide from you, so you don't have to worry about it. You just put data there. And you can run the Elastic MapReduce, which runs on that. So, it's very similar and shares a lot of stuff with Hadoop, but it's not, it isn't exactly the same.
Yeah, but didn't look into that. No, yeah, I haven't done that with Amazon. But the other cool thing is it's fault tolerance. So, you know, all these crazy corner cases that you'd have to code up yourself, they've done that for you. And they'll even do crazy things that you wouldn't think about doing. Like, one thing Hadoop will do is, let's say you have 20 machines that are in your little Hadoop cluster, right? And you're running a job. And Hadoop detects—the Zookeeper detects—you're only running one job. And the job had eight workers. Like, eight, you know, let's say there's eight mappers. So, Hadoop will say, well, you know, if one of these machines dies, you have to like start the whole thing over again. So, let's just run, like, since you only have eight, let's just duplicate all this work. Like, run it on two machines. And if one of them dies, it's okay. Or another thing they'll do is they'll know, oh, you know, you might be able to like pass some data. Or you might be able to arrange and do a little bit of the reducing in the mapper. Like, these crazy optimizations that like we don't really think about because we're too busy focused on the algorithm. They've done all that grunt work, you know, and they've done all these awesome optimizations. Sort of like using C++ instead of assembly, right?
Yeah. Well, you overstayed sir. I am not so emblazingly boldened to say that. But, okay. Not to call you a liar, but I'll just, okay. So what Crunch is, is Crunch allows you to instead of having to use the kind of off-the-shelf nature of a lot of the stuff that MapReduce does or kind of fit into their paradigm, kind of even going again on what Jason said and extending it even a little further, even more flexibility in how you do these things and just allow the computer to handle it, right? The computers to handle it. Just oh, you take care of this, right? So Crunch is an API for allowing you to at an even higher level say like here's generally the data flow I want. And here's the operations I want to perform. And all right, go. And so if you kind of drew out like oh, I need the data. These two data things need to flow together. I need to do some operation on them. And then once that's done, I make some calculation. And then I need that to flow with another piece of data, you know, and then I want to kind of join those together in like an inner join fashion or something, right? Like, all these kinds of notions could become they're like multiple MapReduce Hadoop jobs that we need to run. And there are, you know, things that you might have to string together very carefully. But Crunch allows you to just kind of specify like these are the way I want it to do. And it'll handle like oh, I could merge these two together and run them at the same time. Or, oh, I need to spin up a new Hadoop run for this thing or for that thing. And it kind of allows you to do that much more simply and easily and in a way that's flexible, just allowing the computer to handle it.
Yeah, yeah. And Crunch feels more like Java, you know, because you have these like P-tables, which are basically like they feel a lot like HashMaps in Java. So you can kind of take your existing Java code and if you need it to run on like a thousand machines, you know, it's not just a copy-paste or you can't just change HashMap to P-table. There's more to it than that. But it has things like get all the values, like get a list of all the values that exists in HashMap and also in P-table. And so it kind of feels more like you're just doing native Java. So it's good for people who want to get started with Hadoop and aren't used to writing this kind of stuff.
Yeah, so that idea like P-table or P-group table. And it allows you to say like oh, and everything in that, you know, in parallel do this thing, right? Like, go through and perform some operation. So that's what I was kind of talking about, maybe a little too high of a level. But, you know, that's how, you know, you kind of it gives you this API. But it really is kind of almost, you know, classes and things that make it just look like, to Jason's point, it looks like you're writing Java code on some fancy, you know, HashMap. And in reality, you're instructing Crunch to, in the back end, figure out how to arrange the MapReduces and to be able to do that.
Yeah, totally, totally. So there are some weaknesses to MapReduce. No. I know. After we sang the praises? You'd think it would be just a panacea that would just be a cure-all. But no. One of the problems with MapReduce is it takes a long time to spin up and spin down. And so what we mean when we say that is spin up refers to, for example, let's say you're building a multi-threaded program. So the first thing you'll do is make the thread pool and actually ask the operating system for the threads. So that's kind of like our spin up time, right? And so to ask the operating system for some threads happens in what? Milliseconds? Maybe even less than that? Microseconds? But to ask MapReduce for 100 machines to do work on, or to ask a Hadoop Zookeeper for 100 machines, is going to take on the order of seconds at least. I mean, it really just depends on your cluster. But it's not going to take milli or microseconds, right? So if you have, you know, a MapReduce job that adds two numbers, like goes through two files and then adds the numbers together and the files are a meg each, you might just want to do that in C++, you know? Because by the time you spin up the machines, you know, send numbers to the machines and, you know, then compute the result and then store the results somewhere, yeah, your C++ program would have run like 40,000 times or something. So there is a problem there, yeah. There is something called worker pools, and the idea is, you know, if I have a job that I want to run over and over again, I can sort of prep Hadoop and I can say, look, Hadoop, you're going to do this thing 100 times. So get ready for that, and then it'll do some optimizations there.
Also, we talked about all these wonderful things of bringing on new computers and bringing down computers and all these stages and divide it and just oh, do this little bit of work and then do this little bit of work. And that helps it be really scalable. But, I mean, as you can imagine, all the data that's in your program, all those classes and everything need to be able to be serialized out. And then when they're read back in, they need to be de-serialized. And sometimes, you know, oh, it can be said like oh, I'm going to do this on the same machine. But a lot of times you have to do it anyways because you don't know like, oh, am I going to be doing this on the same shard or not? Or is it going to go somewhere else? Yeah. And so if that takes a long time because you have especially some nasty intricacies, it could be a problem. But even just in general, like, that's going to be overhead.
Yeah. And then the other thing, and there's some theoretical reasons why this is true that I'm not going to get into because it takes a long time. But there's excessive, there's a lot of materialization. So, you know, each of your mappers, going back to our Word count example, each of those things that scans one page of the web has to put those results, all those key value pairs, on disk, on that Hadoop file system. And then the reducer, the shuffler, sorry, that's putting together all the keys has to read those from disk and then put the reduced key values lists on disk. And then the reducer has to read from disk and then put the answer on disk, right? If you were just writing some C++ program, you would just put everything in memory. Or maybe you would only put, you know, a bit of that on disk, like one stage of that on disk. So there's a lot of disk I/O when you're using Hadoop. There are some tools to sort of make Hadoop a little easier to use. One of them is Pig, Pig and Hive. And so they're good for if you don't want to have to write raw Hadoop code, you can just put your data in Hive or put your data in a flat file, like a text file. Then you use something like Pig or Hive. They have their own programming languages, which are much more terse than Hadoop.
So what is Hadoop used for? What is MapReduce used for? Everything? Everything. Everything? I think there was, in the white paper, the original white paper on MapReduce, they said that it was, I don't remember, I think it was over half of computations at Google were part of a MapReduce. I think it was some very large number. Oh, interesting. Yeah. So, and Google is like a huge company. So, you know, and I think, I'm pretty sure Facebook and all these companies have probably similar statistics.
It's kind of interesting to see what companies will say what, right? It's kind of like a little bit of a game. Like, oh, hey, we're doing this. Well, we're doing, you know, but you know, it's like, who knows, like how, what percentage of the actual value of those things are. They're just like kind of one-upping each other. Yeah. But only like slightly, and the others are just keeping quiet in the corner, and it's like, oh, are they embarrassed? Or like, do they like, oh, this is ridiculous. I'm just laughing, right? Yeah, exactly. It is kind of interesting. But I mean, no, seriously, I mean, MapReduce, it pops up all over the places. Like, you know, even for doing like image processing, like, oh, you want to like do a whole bunch of, you know, look for objects in something, or you want to run the same little algorithm on things. I mean, people have done MapReduce to do that. Yeah. People have done MapReduce, even for like, I saw one guy who's writing a little bit tutorial. Like, I think he was trying to convert old PDFs and do OCR on them. Like you had a whole bunch of them, like each page of an old book that has been scanned was like a either just an image or a PDF. And you want to do like OCR on all of them, right? And like, then put them somewhere. But you could imagine, like, if you have millions and millions of these pages, it would just be a nightmare to figure out like a C++ framework and structure or Java structure to kind of do that. That could just, I mean, it could take a long time. But that, I mean, that's right in the wheelhouse of MapReduce.
Yeah, yeah, totally. Yeah, there's a ton of things you can do with MapReduce. The biggest thing is, you know, especially as sort of like, let's say you're an indie developer, you're developing writing code out of your house, right? But you want to do really big data kind of things. Like, for example, let's say you have a website and you have a few thousand people on your website and you're capturing all their clicks and things like that. Let's just take, let's say your website has a thousand people a day. And each person click, like on average, there's a thousand people. And each person clicks once a minute. So there's how many minutes in a day? I don't know. Let's just say they click once in a day. Okay. So you have a thousand clicks a day. That's still 30,000 clicks a month. So if you wanted to go back through a year's worth of data, that's what? So 365,000 clicks, that's a lot of data. And so, you know, you don't even want to do that on your machine because it's going to take forever. So if you wrote a MapReduce, you could say, you know, run it on your machine on like one day's data, make sure it works. And then say, look, Amazon, you know, you have this elastic cloud that's totally awesome. You know, chug on this data, like run this MapReduce that I wrote. And, you know, Amazon will charge you however much that costs, maybe five bucks or something. Sure.
See you later. The intro music is Axo by Binar Pilot. Programming Throwdown is distributed under a Creative Commons Attribution Share Alike 2.0. You're free to share, copy, distribute, transmit the work, to remix, adapt the work. But you must provide attribution to Patrick and I and share alike in kind. Have fun.
