hey everyone and welcome back to the channel uh for those of you who are new here my name is Jordan I'm a Google software engineer and uh in today's video I will be beginning my refactored systems design interview Series so uh I am absolutely a hypocrite for this in the sense that I said I didn't want to make redundant content on my channel uh but at the same time um one of the biggest pieces of feedback that I received and my last series was that even though the content was very rich uh I often didn't give a lot of visual aid and uh trust me you know I understand that visual aid is very important you know for example try you know doing your thing without Pub or something it would be real tough so with all these things in mind um you know I've acquired an iPad I don't really know how to use it very well my drawing skills are very bad and my hands are shaky but uh you know worse comes to worse the iPad is going to make certain parts of my life a lot easier and uh yeah my ultimate goal is to make content on this channel that is pretty much as good as all those paid courses for these grifting Tech YouTubers uh with the exception that it is completely free in fact I hope to make it better because uh yeah you know I'm just going to try and do a really really thorough Deep dive on everything and unlike my last series that I kind of made I'm hoping to even do smaller chunks per video for a couple of reasons one is that it's more digestible and the other reason is that I'm a lazy and I don't like editing that much and so I figure that you know it's a win-win for the both of us if this series takes a little bit longer by doing less per video so with that all being said if you're new here or if you're new to systems design in general I think this series will be super useful for you it really does cover a lot so you know expect to learn a lot and uh you know this is a great time to start learning because the econom is in a downturn at the moment but in 6 months to a year when this series is finished you know jobs are probably going to be pretty hot again and uh you're going to want to get a Refresh on that RSU price so all those things being considered uh let's jump into it we can go ahead and do a little examp example of what systems design kind of means or is or the considerations that you might have on the iPad and I will do my best to make it understandable for all of you uh have a happy New Year and let's get into it all right let's go ahead and get into this so to kind of frame the systems design interview as a problem it's basically something like this you're a website you are perhaps even just an internal infrastructural service with a lot of usage right so much so to the point that just storing everything on one machine is not sufficient anymore and so let's give an example of that so here I am drawing myself on screen as you can see I've drawn myself to figure absolutely jacked and muscular so this is me and in the context of a website like a social media website let's say Facebook for example I am what is known as the client I make requests to the servers of the social media website and in exchange I expect data so let's go ahead and show that tradeoff here I am drawing a nice little arrow and then if we're talking about Facebook for example here is the Facebook application server which will probably be located in one of their data centers so now what I'm asking for from Facebook is some data at some point I probably stored something like a profile picture there I stored some information about myself or my past posts and I want to get it back from them if Facebook didn't store this data in the first place how could they possibly leak it so here we go and we have these Facebook servers and so the question is now uh kind of one of the ways that I want to start thinking about these problems is where do we actually store the data so before we even think of you know what servers we store the data on let's think about what Hardware we store the data on so when it comes to uh data in general and computers there are two basic places that you can put it and one is Ram you know it looks like a little long rectangular skinny dick chip and that is good for Random Access or basically short for Random Access Memory but it's good for temporary storage of data you know that's where we do our computations when we're coding if you're writing like a for Loop you're adding a couple numbers uh technically you know a lot of that's going on in CPU registers but eventually it's going to get stored uh with the variables in Ram and in addition to that we have our HDD or our hard drive and so this is you I'm sure you've seen this before looks almost like an iPad but with a nice little skinny metal disc in the middle and then this kind of point which points to a specific part of the dis again paron my bad drawing skills and the good thing about hard drives is that can actually permanently store data at least in the sense that the hard drive itself is not broken or you know other extenda circumstances so when we are actually going to store data for a company like Facebook we want to obviously put that on the hard drive why because servers can shut down at any given time you know maybe someone unplugs the power and if that were to happen we don't want to lose the data of course you know hard drives can be broken two and we have to think about more than that but uh at least for now let's just think we're storing our data on this hard drive and that's going to be a little bit slower than Ram but we'll touch upon this in future episodes this is mainly just for an introduction so the next question is what computer do we actually put uh this data on every computer has a hard drive but which computer is the one actually holding the data should it be the Facebook application server well actually the answer is probably not and why is this well for starters the Facebook application server is not just talking to me it's talking to a bunch of other people right here are all these other betas throughout the world even though I'm the alpha unfortunately I have to contact the same servers as them and So eventually they're going to be so many people that just one application server to talk to all these people isn't going to be enough I'm actually going to need more and so you know we've got all these other servers and if we were to actually store you know my specific profile data on the original server now that's going to be a problem because when these guys go ahead and contact other servers they're not actually going to be able to see their data they're not going to have access to it and so in this sense we want our data itself to be scalable in a way that is separate from our application servers the application servers or at least the user requests to application servers typically becomes a bottleneck to the performance of our website before the actual accessing of the data does uh typically that's because there's things like caching where we can temporarily store some of the data on these servers and you know that that makes things easier but again this is all stuff we're going to get into later so what we really want to be doing instead is basically having one other computer in the background you'll see I'll draw it as this cylinder here and this is what I'll call a database the database is only responsible for being basically the sole source of truth of all of that profile data Post history all of these things and now application servers can go ahead and just ask the database for specific data about profiles my users all my Facebook history etc etc etc this is completely oversimplified right the truth of the matter is when you have so many users even one database isn't going to be enough right we could make the computer that the database is located on more powerful but eventually even that's not good enough there's simply just too many humans in the world and so the main kind of point of systems design is how can we make the fetching and storing of this data faster both in reads and writs and more reliable what do I mean by more reliable and I mean fault tolerant what if I were to unplug the computer that the database was on now I could never fetch my post history because all these application servers would fail to contact the database so what that means is we have to come up with ways to basically have backups if there's too much data for one database we may have to actually split the data into multiple databases and be smart about that and again pretty much all of this just arises from complications of having tons and tons of users on these massive websites and so in order to kind of first tackle the problem of covering all of these systems design interview tips I prefer to kind of start with the inside out in the sense that I'm going to start from the database and slowly slowly move towards kind of the client layer right going to the application servers thinking about caching things like that and if you know what those terms mean that's great if you don't no worries we're going to learn all of them and it's going to take a while but ultimately it will be well worth it so guys thank you for watching the first episode I hope that this format of teaching works well for you in the sense that I will now mostly be doing a lot of writing on the iPad uh but at the end of the day we're all going to learn a lot I'm still learning a lot by teaching this and uh yeah let's do our best have a happy New Year again