System Design Basics: Horizontal vs. Vertical Scaling

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this videos on the basics of system design if you have never designed a system before this is probably the place to start so imagine you have a computer with you in which you have written an algorithm so some code is running on this computer and this code is like a normal function it takes some input and it gives out an output now people look at this code and they decide that this is really useful to them so they're ready to pay you so that they can use that code now you cannot go around giving your computer to everybody so what you do is you expose your code using some protocol which is going to be running on the Internet and by exposing your cool using something called an API application programming interface when your code does run it will give an output and instead of storing that in the file or storing it in some database or something like that you return that and that's called the response interestingly the thing that is sent to you is called a request where people request you so that's what it is there's a request sent and for each request there's a corresponding response that your computer will be sending back imagine setting up this computer it might require a database to be connected to it it's within the desktop itself you might require to configure these endpoints that people are connecting to and you also need to take into consideration what happens if there's a power loss if someone pulls the plug or something like that you cannot afford to have your service go down because there's lots of people paying money for you you should host your services on the cloud so what's the difference between a desktop and a cloud nothing really the cloud is a set of computers that somebody provides to you for money of course so if you pay a cloud solution for example Amazon Web Services which is the most popular one if you pay these guys they're going to give you computation power the computation power is nothing but a desktop that they have somewhere which can run your algorithm how will you actually store your algorithm in that desktop well you can do something like a remote login into that desktop that's what the cloud is it's a set of desktops not necessarily desktops but a set of computers that you can use to run your service the reason we like to do this is because the configuration the settings the reliability can be taken care of to a large extent by the solution providers so now that we have our server hosted on a cloud which is basically some computer that we don't know about we can focus on the business requirements what business requirements could we possibly have well there's lots of people who are using algorithm now and it gets to a point where the code that you have running on the machine is not able to handle all of these connections so what do you do one of the solutions is to buy a bigger machine right this is solution number one the solution number two is to buy more machines the ability to handle more requests by buying more machines or buying bigger machines is called scalability this is a very important term that we need to understand well like we said we can handle more requests by throwing more money at the problem when you are buying bigger machines it means that your computer is going to be larger and therefore it can process the requests faster so that is called vertical scaling and when you are buying more machines it means that the request can fall on any one of these machines and it will be processed but because you are more of them the requests can be randomly distributed amongst the machines that you have just bought and that is called horizontal scaling these are two mechanisms by which you can increase the scalability of your system like we said scalability is being able to handle more requests like any two approaches we can compare them with their pros and cons the first one that we have talked about is we need some sort of load balancing here well that's not the case you if you have a single machine there's no load to balance as such this second point is that with lots of machines if one of the machine fails you can redirect the requests to the other ones while over here there's a single point of failure so this is a single point failure and here it is resilient the third thing to note is that all the communication that we have between the server's will be over the network and network calls are slow its IO while over here you have inter process communication so that is quite fast so here there is inter process communication while over here we have Network calls between two services so that is a remote procedure calls so this is slow and this is fast the fourth point is data consistency for example let's say you are having a transaction where three sends some data to 4 and then 4 sends it to 5 and 5 cents into 1 here you see that the data is complicated to maintain if there is a transaction where the operation has to be atomic what could happen is that we have to lock all the servers right all the databases that they're using which is impractical so usually what happens is we have some sort of lose transactional guarantee and that's that's the reason why here the data consistency is a real issue while over here there's just one system on which all the data resides and that's why this is consistent the final point deals with some hardware limitations that you are going to have because if we cannot just make the computer bigger and bigger and bigger and solve the problem there's going to be some Hardware limit that we have here point number 5 and over here this scales well in a sense that the the amount of servers that you throw at the problem is almost linear in terms of how many users are added these are the five key differences that vertical scaling and horizontal scaling have so what do you think is used in the real world both we take some of the good qualities of vertical scaling which is really fast inter process communication and the data being consistent so the cache is going to be consistent there's no dirty reads dirty writes so to speak we take these two good qualities from here and we take these two good qualities from here which is its skills well because this is a hardware limit over here and it's also resilient in the sense that if one of the server crashes somebody else can come up okay so the hybrid solution is essentially horizontal scaling only where each machine has a big box I mean each machine you try to take as big a box as possible as feasible money-wise and then we pick up a solution this way initially you can vertical scale as much as you like later on when your users start trusting you you should probably go for horizontal scaling so these are the major considerations we have when designing a system is it scalable is it resilient and is it consistent with these qualities there's always going to be some trade-offs that we have and that's what system design is we design a system which is going to meet the requirements and the requirements are such that it's going to be computer science ways possible to actually build a system like this if you have any doubts or suggestions you can leave them in the comments below if you want notifications for further videos hit the subscribe button and I'll see you next time
Info
Channel: Gaurav Sen
Views: 670,652
Rating: 4.9610815 out of 5
Keywords: system design, horizontal scaling, vertical scaling, horizontal vs vertical scaling, system design basics, basics of system design, system design fundamentals, system design for beginners, beginners guide to system design, scalability, scalability basics, gaurav sen, gkcs, guide to system design, system design tutorial
Id: xpDnVSmNFX0
Channel Id: undefined
Length: 7min 56sec (476 seconds)
Published: Sun Jul 29 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.