Load Balancing
I'm really excited because I've got myself a web server serving something cool
whatever it is you know the do my web app or whatever it might be some real happy
with my web server.
In fact I'm just going to put w w w appear to remind us it's a web server.
I'm so happy with my web server because more and more people are accessing my web
server and after a while I need some help because I've got so many people accessing
my web server that it's slowing this guy down.
So what I need to do is come up with a way to have lots and lots of web servers but
if I have lots and lots of web servers they have to be giving out the same thing
and they have to be doing it at the same time and there could be a lot of
challenges.
So what we're going to talk about in this episode is load balancing load balancing.
Simply means to be able to have lots of servers giving out the same thing and to do
it in a nice even way.
We're going to be using web servers here but it's not limited to web servers as all
kinds of stuff that uses load balancing.
But let's stick with the web because everybody is comfortable with that.
So the first thing is going to be happening here is I'm going to start adding more
servers now as I add more servers.
These servers are passing out the exact same thing the exact same web pages now.
Let's assume for a moment that these web servers are physically in the same room.
OK now what I want to do is I want to have the ability to not overload any one of
these to space out the requests across the three servers.
Now there's a lot of different ways to do this.
Load balancing.
The first way I want to talk it is kind of an old fashioned way but it's on the
exam so it's worth mentioning.
And that's using a DNS server.
So I've got a DNS server someplace else.
That's actually the authoritative server for this particular domain.
And what we're going to do is we're going to put stuff inside the DNS server to
kind of fool people so I'm going to call this WW one w to be 2 and W to be 3 and we
can create is a lookup zone that does something very very interesting called round
robin with a round robin what I'll do.
I'm going to have all three of these guys in a lookup zone and I'm going to have a
kind of a special DNS server and with this DNS server does is it when a request
comes in.
First he gives a new number one the next request comes in that he gives a number to
next request comes in.
He gives it to number three.
This is by about the first generation of load balancing called round robin and it
worked OK but there were some problems with it for example.
Remember that if I as a client access this website I'm going to cache the IP
address.
So what will happen is next time I try to get to this particular site I'm not going
to use this DNS server.
I've already got say this guy's IP address so round robin load balancing was kind
of the first generation had a few problems but they worked on it.
The other big issue that comes into play with load balancing is what if all these
computers are different continents.
Now this is a big thing that a lot of us do because it's a lot faster to get to it
physically close server than one that's far away.
So the other thing we'll do is another DNS feature called delegation.
Here's my eraser with delegation what we'll do is we'll set up another.
But it's going to have sub zones for each of these and most importantly it's going
to have a reverse lookup zone with different P-T are records for each of these.
Now this does something really interesting the world of DNS will start taking place
as if I have some client over here when he comes in does tries to query to this guy
he might.
He's going to try to get to the zone that's closest to him and what will happen is
you'll have this DNS server and another DNS server someplace else and they'll
actually compete for resolving that particular DNS and what will happen is based on
the amount of time to get on the pointer value you really end up going with the
closest one.
And this is a very common way to handle load balancing just using DNS.
The problem with DNS load balancing is that you're counting on a third tool DNS to
do what you need to do.
So a lot of times what will happen is that we will dump DNS completely and instead
do what's known as server side load balancing server side load balancing usually
involves some kind of very very smart device running very very smart software that
is physically at the location of your servers.
There are some real benefits to having your web servers or whatever servers you
might have at the same physical location.
One big benefit is we can take advantage of something called clustering with
clustering what we'll do is we will have separate machines or at least separate
virtual machines.
But what they'll do is they will actually talk to each other on the backend they
will have their own little private network and with this little back in private
network does separate network cards and everything.
Make sure that all three of these systems are absolutely identical at all times.
For example if you have a database involved or something like that these guys can
all update each other.
Even more interesting when you're using clustering you can usually offload all of
your data to a separate device and all three of these will simply just read off
that.
So if you add a new game or if you add a new customer record you're not trying to
add it to three different machines you're just adding it to one database so
clustering is a huge benefit.
So when we're doing the server side like this we get some other really cool
features.
First of all this smart box this load balancer can actually talk to these guys
individually and by talking to them individually we can do some cool things.
Cool thing number one he can actually query him go.
Are you busy right now.
He can see who's the least busy and then send that data over to that particular
machine.
If the machine goes down he can automatically reroute without any problems
whatsoever.
This guy can even act as a proxy server for example.
This box right here can handle all the SSL if you're on a Web site he can be a
certificate server and handle all this and take that load off of these individual
machines.
So load balancing is an incredibly powerful tool.
Now right here you'll notice I'm showing this is a box.
What's fascinating in today's world is that most people if you have a website
anymore it's probably going to be on the cloud.
So what will happen is you'll have three or four instances of your particular web
app your web page or whatever it might be and even the load balancer these days is
virtualise.
So all of this is really nothing more than software and where it's running we don't
care because the beautiful part about it is that load balancing works.
Now there are some features about load balancing you need be careful about.
Let's just say for example I'm a client and I get assigned to this machine.
Well if I'm assigned to this machine I might have some certain things going on at
any given moment that I want to get back to that machine.
And even though the load says oh he's the slow one now.
A good load balancer will sit there go out you have a session with this particular
client as long as your session lasts.
I'm not going to move you to another machine.
I'll keep you on that machine until your particular session is done.
So this is just a real basic idea of load balancing.
It's a fascinating world and you get to add all kinds of interesting boxes to your
network to take care of these things.
But do keep in mind that there's really two big chunks to load balancing at least
for the exam.
There's going to be DNS solutions and then server side solutions.
Make sure you're comfortable with those two.
Load balancing can be configured as client-side or server-side and provides high
availability
Load balancing can route to the most available server, either by a configured list
(round robin) or by least response time
Server-side load balancing uses a sophisticated hardware device that is located
within the server