Anycast IP - How does it help in reducing latency?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello YouTube this is a data here back with another video and today we're going to look at how big companies like Microsoft Google Facebook and all these companies reduce the latency of their application using concept called as any cost okay so before we get started I have two quick things to talk about this is my first whiteboard video so I'm not really sure how good the video is going to be or how good the recording of the bolt is going to be so I'm going to keep improving upon it by receiving your feedback so that is really important please do give me feedback based on the clarity or you know anything the voice this is a new you a microphone that I have as well so that is the first thing second thing is I am looking at reaching hundred subscribers after this video so the next thing that I am planning for you guys is a complete playlist on how operating systems work so that is going to be quite interesting as well and I'm going to plan or I'm going to start working on that only after I teach hundred subscribers so I'm currently at ninety and I just need ten more subscribers to reach hundred okay that being said let's quickly get started with the topic for today so let us start off by taking a very simple example let's say I have a networking website register the domain name abc.com and let's say I have my servers for this website in America okay just to clarify I have drawn like different regions around the world this stands for United States and here we have Africa here we have India and here we have Austria okay this is just for reference so let's assume I have developed the social networking website and I'm hosting it in a datacenter in America so what will happen is this is going to be your global website right everyone in the world should be able to access this I want a lot of traffic coming across the globe I want to connect all the people across the globe by on my website okay so here what we will be doing is we one who is this website on those which are present in this data center okay the next step would be to see what problems can occur in this case right so let's say there is a user in India who is trying to register on those social networking site and who's trying to become a member what's been happening for the Indian customer or the Indian user is the in user will have to travel it all the way it is this data center to talk to this application because it was present only in one datacenter right so then this is where the latency comes into picture however fast the Internet is it is going to take more time for an Indian user to access this website as compared to a person sitting in u.s. okay so this is kind of a partiality that you're having which isn't good you would want to reduce the latency as much as possible to all the users across the world right so what do you start seeing is the users were trying to connect to the website start seeing a lot of latency or a lot of slowness in the page loading okay and sometimes they might also get really angry and they might not even register to your website because it's taking a long time to load the simplest solution here which I can think of right now is to have like one data center in every region right you just have your application posted in every region okay so so you're considering only four agency where okay you have your application installed in every region by this the problem that you will have is to synchronize your applications so let's say you want to deploy a latest version of the website it would be difficult for you to deploy across all but that can somehow be managed that is not at all the problem no the next thing that you would want to understand here is how would the Indian customers me routed to only the servers which are in India I do not have to go take us to access the website so this is done by using DNS again and if you hybrid to watch the DNS video of mine I would recommend you to watch that so let's see what happens okay so let's I this is our website and we buy for eyepiece okay because there are different regions for simplicity we just wanna call them 1 2 1 2 . 2 3.3 and 4.4 ok what do is we're gonna associate each of these IPS to each of these regions right so do you wanna have my not one unit you would have we won't have 3.3 for India ok so now we have kind of isolated the website two different regions okay the next step would be to have or smart DNS reply based on the region so let's assume there is if we get user well who's trying to access the website which is in the data center which is present in India what we would require is let's assume this is the entire DNS process which happens so the Indian user contacts the DNS requests for an IPO of abc.com and the DNS should be smart enough to recognize the IP and the geography okay so we're gonna have a mapping based on the user's IP ok from that the users coming and we are going to accordingly send him though IP which is 3.3 here okay so you're not a vegetable via bono or the DNS or software or whatever we are using we are going to look at the geography of the person who's coming ok let's say a person is requesting from India before I really send all the response a screed or three because we want the Indian user to contact the server present in India okay now here as you see there is a wastage of a lot of IPs this is considering just four regions there are multiple regions in the world that you will have to keep to a two so you will require one IP for each region if you go with this method okay and what what else do happen here so your DNS be smart enough to basically compute the IP addresses of the entire world every day or whatever duration you set at us and it should be able to associate that with the geography so why am I telling this let's think about that a little bit so let's assume you are you have internet connection to your house and you have been assigned an IP address let's assume it's a public IP address for now oh you mean I assigned a public IP address but there is no guarantee that that IP address belongs to you forever the ISP can you know refresh your IP address he can allocate that IP address to someone else unless you have a deal with the ISP sink this is a static IP address that I want okay so because of this a lot of IP addresses across the world between ISPs keep getting reshuffled okay though I tell us that I have today might all of a sudden belong to someone sitting in the US or just in two days okay so what will happen is the person who's contacting from us the DNS you have the software that you have for DNS or looks at the geo and IP mapping it gets this IP address from the person in u.s. it maps it to India because this I belong to an Indian use of the phone and it's going to send the user to the Indian DC okay it's gonna send the user to this server that we have in India and again it's gonna increase the latency for the person who's accessing from us okay we want to avoid this as well this is not a good thing to happen okay the next thing that we can see is let's say the data center in India went down due to some reason okay let's assume that is a power outage or let's assume it has been hit West or some some natural calamity so if this data center goes down and let's say indeed user the strength tax is the website it's very common that the data center has gone down but the users are still are they distill what axe is the website right they are not going to go anywhere if the data center is not so what will happen is the Indian user will go to the DNS the Indian user will ask for IP for the website abc.com and since the DMS returns 3.3 it tries going to the soul which is dumb like this over doesn't exist is being blown out okay and what happens is all if I had an Indian users are all blocked from accessing the website is it because one day doesn't two men down were these Indian users are not able to access the website this is a pretty bad scenario so how do you solve that what we do is we have something like a health check okay built into the DMS again yeah overcomplicating DNS it's supposed to be as simple as possible wherein you request for the IP for the website and it just responds but you'll be kind of complicating it by associating geoip to it and now we are also building one more smart solution which is normal health check that it does to the service ok so this is an additional service let me put it in so you are adding more additional health check ok which keeps contacting the Indian DC or the servers are in the indian data center to see if it is still sending a response so as soon as this data center goes down it will update in DNS that this IP does not exist anymore the servers are dumb and it will start read out second you must let's say it's Australia and you wanna start redirecting Indian users to Australian or data centers shows ok so this is what will start happening once the data center stone but the catcher is there is something called is time to live in DNS rate as we discussed in a previous video so what will happen is you have a TTL which is set for this DNS and this can be instantly changed to serve this but then there are multiple levels of details which have to be bypassed so for example all the again users will have a detail in the cache in the local operating system cache right so that has to expire then let's say the browser has a TTL cache that has to expire and when they after all of that is where it will hit the DNS server again and that's when it will get a response for food or food and only after that the Indian users will start accessing Australian or suppose so basically what I'm trying to explain is there is a small amount of duration when the entire service of the entire social okay website is down for some users okay in our case it's going to be Indian users he wouldn't want this to happen so here's where the next solution comes into picture which is any cost okay and let me quickly it is this and let's look at how any cost works we did realize that geoip based DNS solution was not working really well for us so the next thing that we can look at is how to utilize any cost IP concept or to do the same thing here okay so if we look at it and we have one IP okay we have 1.1.1 first 1.1 and we are again going to just call it 1.1 for simplicity what we want to do is in the DNS servers across the blue we're gonna update the IP of abc.com as one okay so in this case when we are utilizing or when we're making use of any cost we are going to buy only one IP for the entire website we do not require multiple IDs okay so once we have 1.1 associated with abc.com what you do is you do not really require the entire data center to be present present in all the regions what you will require however is something called as a pop okay this is this stands for point of presence so basically we have a point of presence for this website or for the service across the world okay so we have a pop in Africa we have a pole again in India we have a pop in Australia okay just to clarify things you do not necessarily need to have only one pop in one region you can have like thousands of pops it just depends on how much money you are ready to share it and how much of complications you require in your entire architecture okay so now coming back let's see what happens when someone I start to see abc.com okay some Indian user again let us take the same example the Indian user tries to access abc.com he queries the so switches present cure okay all right what happens is the DNS response with 200 1.1.1 okay one point out one night and the indian use of the solution is this IP to be able to access the website now what's going to happen this is the Indian users or is going to access this data center again because this is the only place we have associated the site okay by associating an IP what I mean is we are going to bind the IP to the server and we're gonna are now introducing BGP okay the bgp router which is present at each of should start announcing that though so well inside the bgp router road behind the bgp router owns that IP okay so basically bgp peering discovered in one more video of mine and i will just link it to the video and talk you so you can go check that out as well so based on bgp peering what is gonna happen is each of these pop-ups will have a bgp router in front of them and they will start advertising that they own one top one so the datacenter here we're going to start adding my own 1.1 the poker will start telling ioann one knows one the all clear in australia which is the same and the same an idea as well so once the announcements start taking place over a bgp peering and bgp announcements oh what will happen is the routers near the pool let's assume these are the routers okay all these routers start computing the routes to the nearest IP okay let's assume this user in india wants to access 1.1 all these around pools basically have the routes to 1.1 ok let's just take one router here is an example let's assume this router is where this user is going to fit this around to it has announce for all the one not ones which are present okay it knows that it can reach 1.1 in maybe 50 waves or whatever and it starts computing the or part which is the best for it okay in this case we can talk about maybe the shortest path the least number of hops to these one or maybe the least amount of time that it takes to reach one to one or the maximum bandwidth having the route which it can be choosing the route so all those are P computed and let's assume we have 50 routes present and it is going to select the or which is announcing 1.1 in India because that is going to be the shortest or the least latency path that it can reach right so basically this router will find out a way to reach 1.1 in the least time or the shortest way possible and what happens is the routes each of the cable which is connected between two routers has a weight associated with it and that's all the entire weight for the part between this router and the BOP is computed ok similarly does for all the Pops in the world and it is able to tell that the Indian pop is what it can reach the fastest okay that's how it it's the Indian and that's all the Indian user is a router only tuning in this is a small trick that we have in BGP which we use and we are able to solve traffic based on the geographic locations or the closest Soward to the particular user who's requesting ok this being said what is what happened now is one of the users in India I am going to get redirected to a pop which is the closest to them let's assume there are two oxen India's with the users were closer to the Pope or the least time they will take to reach to the Pope will be redirected to no particular Pole so let us look at the same problem that we had encountered in the previous situation right let me erase these routers we do not really require so many routers for now it's just making this look bad so let us assume this goes down okay what is going to happen in that case is all the Indian users who are trying to access the server in that particular pop will no longer be able to access it just like a previous scenario right so what happens now is the user will again contact the DNS the DNS will 1.1 and the user is going to the next router and basically the parts which are computed here are going to change okay check which keeps happening as soon as this pump stops announcing 1.1 because it goes down due to several reasons is when all those will change their paths they have already configured the entire path and they're going to see which is the next nearest of the next closest that they need to hit in order to access the same back side okay so the users are no longer going to go to this forum but they will go to the pub in Austria assuming that is the closest one to them okay and since the users are redirected to Australia immediately this is not going to show any downtime for the particular social networking website whatever happens you will have this pop Goes Down they will start getting redirected to the next closest pop the latency for the users might increase but it's going to increase by a very small amount considered considering our previous scenario where the entire site would have gone down for several minutes or whatever till the TTL expires right so this is going to be a much better solution or when you want your site's latency to be reduced and it to be available for a longer duration of the next thing that you can also look at is let's consider a DDoS attack happening on our site okay let's assume there is a hot car sitting somewhere okay and what happens you know DDoS attack let me quickly explain that so he's going to collect boats across the internet he's going to compromise a lot of users computers okay let's assume there are five users in Africa just for example and there are five users in America and to users in Australia whom he has hacked into and he's going to use these servers or these computers to launch an attack he is going to basically use these how many computers five e + 5 n plus 2 the hacker owns player computers know of innocent users and he's gonna use these computers to start accessing the social networking website as many times as possible so he's gonna basically type or take a lot of load on this particular website okay and once the load increases the server's resources starts getting exhausted and that's all the legitimate users all over one actually access the site are not allowed access because of resource constraints and the sub was going down and all that so in our case since we're using any caste or let's look at what will happen or let's look at a scenario what would have happened when the anycast wasn't used before okay so when the any cash wasn't used we had only one data center in us and we had 20 computers attacking the data center than us right all the traffic across the world would have hit the same data center and this would have led to 12 computers accessing the data center at once okay obviously it's wrong to me just 12 computers there's no that said which will go down and buy computers so this is just for explanation but just all multiply that by like several lakhs or something okay just like 12 million users trying to access us data center at once okay this we hadn't considered for this load so it was natural for the servers in this data center to go down which means the application is not accessible to the entire world no one in the world is able to access this well so it just because one bc went off okay now let's look at a scenario where we have implemented any cost and now the hacker don't use the same attack of it okay so what is gonna happen is these five users are going to go to don't be seen us these file servers are going to go to this pop in Africa and these two users are going to go to the open Australia so basically what we're doing is we're distributing the load okay we are not allowing the hacker to bring down the web site just because she's compromised 20 systems across the world okay this will basically allow the users to still legitimate users to still continue access from the website so this has been a really good solution to mitigate DDoS but again hackers are of evil and they're able to come up with new solutions so what they do is they start compromising a lost lot of hosts in the same region okay in u.s. itself they get query system the compromised rail systems and they start attacking the same data center in which is the entire DC will go down okay it will be unavailable only for the users in America okay the website will still be accessible for the rest of the world because all the other pops are still active okay so this would still mitigate it to a certain extent but not completely mitigate the issue okay so I had one last thing to cover also all of this is assuming they are going to have the ipv4 and we are going to have this BGP hacky way to spread the traffic to each pump like we send the traffic to the pub based on the IP and based on the closeness of the pop to the particular user in case of ipv6 or they have they have any caste implemented inside ipv6 itself so all the routers which I understand ipv6 have certain number of four IPS allocated in every subject for any cost ok so that simplifies our inter process you do not need the active a of BGP announcements of the same IP across the world ok so you do not require to know all of this so because when you shift ipv6 ok that is all I had for this I just had one interesting question for you guys before we drop off let's assume there are two pops ok this is all one and this is all ok and there is a user who's trying to access the same website again from one of these two pops ok and this is going to be one and this is going to be ok let's assume this is the use of your so now what happens here is let's assume the wait for both of these parts is 50 ok it's computed to be 50 now which pop do you think the user will be routed to because both the pops have got the same orbit so it is up to the user to you know it's not up to the user it is up to the internal network or to decide which to round to the user - okay this is a justic challenge that you can come up with the solution and then you can let me know in the comments as to how you would go about solving this when the user is equidistant or equal weighted across two pops which will the user choose okay one more interesting thing that you can read across is something called as root leaking okay route linking happens and the users are basically flapping between two pops okay and this basically in stabilizes the connection for a particular user is going to one month and he's going to pop to the second time which is really in unstable for the user okay and this does not work in case of PCP because you need to set up the three-way handshake first and then you start accessing the data and when you have SSL over this it over complicates it even more so the best thing about any cost is it is very much suited for applications which are stateless okay which do not require continuous interaction with the user and storing the user's previous session information and all of that that's when any cash works brilliantly and the most widely used application for any cost is our DNS root name systems okay all the root servers in the world there are like 13 root name servers they have used any cost to be able to distribute load and to be able to reduce the latency for the users accessing the DNS servers and getting a response back okay so this is headed a lot in getting the IP of website as quickly as possible I hope you guys understood what any cost is used for and how it works in the real world and how big companies are able to leverage the concept of any cars to reduce the latency of the applications that their users are using I hope you guys are able to implement this in your own organizations if you are able to that is all I had for today's video I hope you liked the video and you took away something from it please do share the video and subscribe to my channel because there are just 10 more subscribers that I need to cross 100 subscribers I would really appreciate it if you just put in your comments in the comment section as well to give me more feedback about how the video end thank you for watching and see you all in the next video
Info
Channel: Aditya Kamat
Views: 6,312
Rating: undefined out of 5
Keywords: SRE, Computer science, Anycast IP, Anycast, Whiteboard, engineering, system design, Applications, latency
Id: MgjVjGMb_xg
Channel Id: undefined
Length: 26min 25sec (1585 seconds)
Published: Sun Jan 12 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.