hello friends welcome to reach goals today I am going to talk about content
delivery network or otherwise called as CDN . In this we are going to
discuss about CDN system design and some of the sample interview questions and
the most interesting interview question is how to explain the content delivery
network to a layman so let us understand what CDN is so basically instead of
having all your content in the origin server you can have the content in your
closest to location which is called as an edge server so that means if a
customer coming and accessing your content they don't want to go to the
origin server often and instead they can get the content from the closest to
location which is called as an edge server so there are a lot of benefits to
that right the first benefit I see here is the speed right so since your content
is not at the origin server always you are not getting your content from the
origin server and you are getting from the edge server which is closest
obviously you're going to have the speed improvement in your system because of
the low latency and because of the data which is travelling to the low network
right the second thing is scalability right so if you are hundreds and
thousands of customer and if they all want to get the content from the origin
server the origin goes server is going to get high traffic and it's going to
get loaded very fast right instead if you have all your content in the closest
location and the traffic to your content or the traffic to your content at the
origin service is gradually reduced in that way you can scale your system
across multiple users or thousands and thousands of users like the third one I
have is origin high uptime what does it mean is if the traffic is not going to
hit very much on your origin server there is a high possibility your origin
server is going to be up for a 99% of of time right so in that way you can keep
your origin server - at a high level right the fourth I have is a security or
DDoS resistance so what what I mean here is if you have all the content put into
your origin server and if a traffic is coming and hitting over your origin
server quite often that is the high possibility of security risk right so
you can have a DDoS attack on your origin server and it can and it can be
tossed right so instead if you have all your content
in each server and the traffic getting into the origin server is reduced there
is a less possibility or less security risk over here in other way in other
ways what we can do is in the red server we can implement a lot of security
policies and make sure you can't filter the filter the security concerns over
there right in that way you can implement the security features in the H
server as well right so the other interesting interview question here is
how to explain the content delivery network to a layman right so if you see
in the screen I have put the pictures like there is a form which is in the
California where I call it as an Origin server right which are producing the
fruits and vegetables and the left side of the screen you see the customers who
are shopping from new art as well as from the Texas right if a buyer or the
customer wants to buy some fruits or vegetables they don't want to go to the
origin server location which is in California right instead they go to the
nearest stores or vegetable stores to buy the products right that is how the
content delivery network also works right so they don't want to they don't
want to go to the origin server if you want to get a web page instead they go
to the 8th server to get the web pages right so what what really helps them is
it reduces the traveling time from the New York to California similarly if you
see if you if you look into the real application what it does is it reduces
the traveling time from the Newark customer to the origin server customer
right the second thing is scalability right if everybody enters to the origin
server the origin server which is a form it's not going to withstand or it's not
going to suffice all this customers right instead all the content is
distributed across different stores and they can go there directly and they can
purchase or pickup whatever products they want right so that is how I'm
trying to correlate the real CDN Network with the a distributed distribution
center of forms and the vegetables vegetable stores right say in this let
us try to understand how the CDN works right so let's say if a customer is in
San Francisco accessing a web page like walmart.com right and the content is or
application is deployed in the origin server which is at the Nuart crane so if
they don't have the Syrian Network what actually happens is they have to access
the content directly from san-francisco location to the New York location which
is really far and it is going to take a lot of time and the latency sky so now
if I have a CDN Network let us see how it works right so there will be a CDN or
location somewhere and you will have lot of H servers right so what happens here
is the content comes and sits in the each server and the user don't want to
go into the origin so instead they can go to the H server through this CDN and
get the content very quickly right and it's server will have the content way
either way it can be directly pushed from the origin server or that server
will be have they will have the capability to get the content from the
origin server and this is one H server they think of the companies like Akamai
or Amazon they have content servers sorry they have the H servers across the
globe and wherever you're accessing they have the closest location and they can
get the content very easily right so they will have n number of its servers
across the globe right so the benefit out of that is let's say if you are
looking at the red line if you want to access from the San Francisco to the
origin server typically it might take 400 milliseconds to get the content
let's say if you have an H server which is closest to say closest to you it
might take 100 milliseconds so that so that so the CDN works right now let us
talk about Sirian system design right if you look at other companies like Amazon
or a kawaii they have their own CDN Network and they are done with their
proprietary algorithms and it is not disclose tried I am trying to build a
system CDN system with the existing infrastructure right and this is a very
common interview question asked of multiple companies like Amazon or
Facebook so in this design what I'm trying to do is I am going to build a
origin server which is in the Newark location where you are going to deploy
your war files or the Java Script files or whatever files which is in the origin
server which is in a new one right the second step what I'm going to do is I'm
going to create the edge server which is which is which is very close to our
customer occasions like Los Angeles or some other
location which is very close to that like Texas line then the next step is I
will go and install the web servers in the all date servers right so basically
the web servers can be engine X or the Tomcat and it has to act like a cache
server right or at all it's kind of a reverse proxy so it should have an
ability to cache the content and it should store in the H servers right so I
can build the its servers in multiple locations like Arizona Texas Florida
right and you can keep on building that across the globe based on your need and
the customer's availability right the next one is I am going to Amazon route
53 and I'm going to configure my DNS in that I can point to multiple it servers
and say that you know I can also configure the policy in such a way right
the the URL whenever it comes from the customer it has to figure out the
closest location and set and deliver the content that is my next step
right once you do that that's it right so when your customer is clear hitting
the traffic from the San Francisco it goes to their route 53 and it determines
the closest location so the closest location for San Francisco is Los
Angeles right so it tries to get the content from the Los Angeles and it
serves the San Francisco customers you know you should also notice something
like you know there is a blue line which connects from Los Angeles to origin
server what it does is there is a web server asset which has been already
installed in the H server it tries to get the latest content from the origin
server and it and it keeps over here so in that way you always have the fresh
content right so there are multiple algorithms to implement in such a way to
get the content or the fresh content from the origin server and you can place
it into your different itch servers which are very close to the customer
locations right so here if you see all the steps whatever I talked in this
slide or clearly mentioned if you want you can't read it and understand that
right now let's talk about some of the production issues which are very common
in the CDN Network the first one is delay in the content to
the cost of customer let's say let's say if you want to display a content exactly
on specific time right now for example freighting right so all the customers
wants to see the refresh to contact 12 midnight because it is a Black Friday
and there are a lot of deals and sales going on right so now if you publish the
content to the origin server it is not going to reflect across the globe at the
same time it is going to take some little bit of time so you have to plan
in such a way the content or display little bit advance so that the contents
which are displayed in sorry the contents which are published in the
origin server gets pushed into the differentiate server based on your need
right second thing is about the caching issue let's say you have hundreds and
thousands of servers deployed across across the globe right now if we don't
see any content at one of the server or if the holds or if the server is having
at the older content it is not going to display the fresh content right so here
it comes to production issues saying that the cache is having the older
content it is not reflected the custom right so what should you do now so the
only option I have seen us you have to clear the cache at the age
servers right so you should be very clear what is the TTL at the each server
and make sure that content is getting cleared appropriately at a certain point
of time so that you know the fresh content gets reflected this is a very
rare case if your if there is some network delay or network issues this
could have happened right otherwise all the software's like Akamai or Amazon
whatever they are giving they have a excellent TTL mechanism where you if you
want to if you are setting a time limit like now at 12 o'clock it all has to all
the content has to be cached it takes care of it right it's a very rare issue
which happens but just I want to tell that you know this could be one of our
production issue which you Dow which which can occur due to the content
delivery networks right thanks for watching