So that's kind of it for the main portion of this lecture. there,
there's not going to be another quiz. But I just want to show you some
more pieces and, and, and what would be a, a, a kind of
a full web stack for a major website. That we haven't really talked
about yet. So we've spent a lot of time in this lecture
talking about the app servers and
databases and cache. And the relationship between
all these things. We also mentioned briefly a load balancer. There's some more
pieces in here that a large website may have. So right now requests
go from the Load Balancer to the Apps servers, who then
go to the DBs, or to the Cache. What if we
get so much traffic that one Load Balancer can't handle it?
Well then we can add a second Load Balancer. But what
load balances the Load Balancer? Well generally you something called DNS
round robin. And what this means is DNS is the system
that converts a domain name into a IP address, and that
generally doesn't happen on your machines. Or that's rather, that's cached all
over the internet. There are DNS machines all over
the internet that all cache each other's information. So what
you would do is you would give, you know, a
website like udacity.com instead of mapping to, you know, one
IP, it may map to, you know, multiple IPs,
one for each load balancer. And then different machines in
different parts of the world or different times of day
or different requests might get sent to different load balancers.
And that's one way to vary, vary high level
to spread huge amounts of traffic across multiple load balancers.
Another thing you may have either behind your load balancers
or in front of them is another cache. And the,
and this is like basically a just a, just an
HTML cache. And this cache may, in, intercept requests before
they even get to the app server. And this may
cache HTML and images you know, all sorts of stuff
that we know are not going to change for this user. Say,
say it's a, a request comes in with no cookie, so no,
the user isn't logged in. We don't have to do any dynamic
request, we don't have to do anything special, well, we can just
cache the entire result of the page. You know, the, all, all
of the HTML we're going to turn not just the database query. Some
examples of this technology are Varnish is a really popular one. We
use this at a, Reddit and Hitmunk, it's really nice. Squid is
another one. And a lot of people build their own because
if you're at this scale you prob you, there's a high likelihood
that you need a custom solution here. But you can have,
basically more caches in front of your app server. Another thing you
can do is use what's called a CDN. And say you,
you know, you have got the whole internet here and CDN is
basically a content delivery network. And
these are usually third party companies
that you would pay to cache your content all over the internet.
So they would intercept your DNS requests. You know, they
have, they have machines all over the world. You have your
you basically have your DNS instead of pointing at your
load balancers, point at the CDN. And it may point at,
you know, may-, maybe do some round robin thing to
different machines and that sort of thing. But basically these machines are
just big caches, just kind of like this varnish cache here that
say, okay, before I even send that request to my customer,
do I already have it cached and these are basically just
a big cache. So the name of the game is caching and
the question is you know at what level do you cache
and we've only been talking about caching DB requests but you can
also cache you know, entire responses or you can pay somebody
else to cache the entire response all over the internet and a
lot of the biggest websites do this. You know Reddit pays a
third party company to do so you know, Facebook and Google have
data centers all over the world. And so, they do it themselves.
But you know, as you grow and grow and grow, the challenges, you
know, how much of this content actually is different on every request
and how much is the same. And content that is the same can
be cached. And you push that cache further and further away from
you and closer and closer to your customer to get higher and higher
speeds. And, when the content can't be cached, you know, you need
to add lots of app servers and internal caches and internal, you know,
custom systems for dealing with this type of load. So, that's kind of
how the whole picture may look, you know, once you're at a huge scale.
So, I hope you enjoyed this lecture. A lot of the stuff in
this lecture I kind of learned the heard way, on Reddit, doing you know,
starting with one machine, and then.
Two machines and splitting apart the services
on all of that. We made a lot of mistakes along the way and
actually in unit seven is, is when I'll talk specifically about the process we
went through of going from one machine to many machines as we were growing.