Hi, everyone, and welcome back.
Now in today's video, we are going to discuss about the application load balances.
Now, before we discuss more in detail about the application load balancer, it is important for us
to understand at a high level overview about the basics of HTTP headers.
Now again, one important thing to note here is that the HTTP headers are not really part of the exams.
But understanding this will allow you to better understand how the application load balancer works.
So at a high level overview, the HTTP headers lets the client and the server pass the additional information
with an HTTP request or HTTP response.
So whenever you open a website, it would primarily use either the HTTP or HTTPS protocol.
And behind the scenes you have various kinds of headers that are passed for the client.
It can be the browser and the server to exchange certain information.
So let us understand this in a better terms.
So I have an application load balancer that is currently running.
Let me copy the URL associated with it and from my browser.
In this case it is Firefox.
I'll go ahead and I'll run the inspect element and let me paste the DNS name here and let's press enter
now in your you see you got a basic response of Hey Mozilla, you have a great add on.
So basically a response was given by the load balancer back to the client.
Now if you inspect this network here, you will see that there are certain HTTP headers that you will
see here.
One of the primary one is the gate request, gate request on this specific load balancer.
So browser is trying to get the contents by making a request to the load balancer.
And the response status is 200.
This is completely fine.
Now if you'll see over here, there are two important things.
First is the host header.
Host header basically determines to which host the request had been sent to.
In this case, it is the DNS over load balancer and you also have a user agent header.
So user agent header basically gives the information about the client to the server.
So in the user agent header, the Firefox will give its information.
So you see it basically states Firefox slash 102 over here.
And apart from that, there are many other headers which will avoid looking into it at this stage.
All right.
So the primary aim at this stage was to understand that whenever you open a website behind the scenes,
there are certain HTTP requests and the HTTP response that are exchanged between a client and the server
client can be something like URL or W gate or client can also be a browser.
Now when we discuss about the application load balancer, know that it functions at the application
layer and it supports both the HTTP as well as the HTTP protocol.
Now, since it works at the application layer, the application load balancer can go ahead and it can
read the contents associated with the headers that are being exchanged between a client and the server.
So it can be this host header, it can be this user agent header and so on.
And based on the contents of the header, the application load balancer can go ahead and draw out the
request to a set of servers, or it can go ahead and perform another set of operations as well.
So let's take a few examples.
So first one is related to path based routing in this what the application load balancer is doing based
on the request you array.
So you have a you array of slash videos or a huge array of slash payment based on this specific array
in the request, there are certain rules in the application load balancer where any request that is
coming to say example dot com slash videos, it will go to server and server two.
So these are the first two servers and any request that goes to example dot com slash payments, it
is directed towards server three and server four.
So let me also show you where exactly this user is captured.
Now, generally in this specific headers that we captured, let's look into the second one which is
associated with icon over here.
Let's go a bit down and within the request headers.
I'll just open up the raw headers over here and within you you see there is a gate request on a specific
path.
In this case the path is fave icon, dot iso.
So this is the path that we are discussing here.
So this path can be anything, it can be slash videos, it can be slash payment and so on.
So depending upon the path that the client is requesting, the application load balancer can route the
request accordingly.
So this is one example.
Now the next example is related to routing using the host headers.
So in this case, what the application load balancer does, it looks into the host header as part of
the HTTP request.
And based on the host header, there are certain rules.
For example, in this diagram you have a host header of example dot com and the destination is server
and server two.
So any time a request that goes to an example dot com reaches the load balancer, load balancer will
send that request to server and server two.
Similarly, you have one more host header of keeping tabs dot in and the destination is server three
and server four whenever the request reaches here.
So similarly, if you look into this from our headers perspective currently you see you have a host
header over here and this host header is a specific URL.
So based on the contents of this URL as well, the application load balancer can make its own decisions
currently within the application load balancer.
I have added certain rules for today's demo and these rules are primarily based on the user agent header.
Now, as we were discussing, if you remember, we.
This user agent header where the client goes ahead and gives information about itself.
So Firefox will give information about itself.
Chrome will give information about itself to identify itself to the server.
Basically itself would mean the tool that is used.
So in the application load balancer that I have available, there are three primary rules.
So first rule is that if the user agent header is called, then a specific response is sent to it.
And if we look into the response party, it is high call.
If the HTTP header user agent is Mozilla, then the response would be Hey Mozilla.
If the user agent header is W gate, then the response is either w wait.
So depending upon the contents of the user agent header, the response from the load balancer is changing.
And this is one of the reasons why whenever we had to open the load balancer URL in our Firefox browser,
it had written this specific response.
So let's do more testing from a different set of clients to see if a different response is being given.
So let's go back.
I'll copy the URL and from my terminal this time I use the client to send the request to a load balancer.
This time, you see, the response is completely different.
It is high curl.
Similarly, we'll use a different tool, let's say w gate to send the request to this specific URL.
And in their response there is a file that is got saved, the file is indexed, that is HTML as you
see over here.
Let's clear the screen.
If we do a cat or an index or HTML.
You see the responses now?
Hi there, w I have detected you.
All right.
So I hope at a high level overview understood on how the application load balancer can look into the
HTTP headers to perform its own decisions.
Now, generally in the application load balancer, whenever you go ahead and add or remove some rules,
let me quickly show you.
So whenever you insert a rule, this rule can be based on various parameters.
You have host header, you have path based routing, the HTTP request method, the HTTP headers and
so on.
And depending upon the header that you capture, let's say I capture HTTP header, it basically is asking
for the header type, let's say user agent and you give a value over here.
Now once the application load balancer detects this specific header in the request that was sent to
it, there are certain actions that can be performed.
It can be forwarded to a set of servers, application load balancer can return a specific response back
and so on.
Great.
So that's the high level overview and this will conclude today's video.