Hi, everyone, and welcome back.
Now in today's video, we are going to discuss about the listeners and target groups in the load balances.
Now, at a high level overview, a listener is a process that checks for the connection request using
the protocol and the port that you configure.
Now, this can be better explained with this diagram where you have the load balancer and this load
balancer has two listeners.
First listener here is associated with the protocol of HTTP port of 80.
Second listener is associated with a protocol of HTTPS and port of four, four, three.
So this would mean that the load balancer, since it has two listeners, will be able to listen both
on the HTTP based request as well as the HTTPS based request.
So let's do one thing.
Let's go ahead and quickly look into it.
Now, currently, I have a sample application load balancer that is available and within here you have
a listener tab and within you can go ahead and add a listener.
Now if you look into the protocol, you have an HTTP, you have a HTTP, send, so on.
Now, depending upon the listener protocol, you can also define your own custom port.
So for example, let's say I add a listener on Port 81.
So that would mean that our load balancer will go ahead and it will listen on Port 81 for the client
requests that are being received.
Now, one of the question that comes is, let's say that this request has come to the load balancer,
which is http example dot com.
Now this is a HTTP based request.
So this went to the listener one since listener one is associated with the port of 80.
Now since this request is associated with listener one, what is the next step?
What will be the action that would be performed on this specific request?
Will this request be sent to the backend server?
Will this request be blocked or some other actions that would be performed on this request?
Let's go ahead and look into it.
So the second important part, as part of the listener is the rule section.
Now each listener has a rule based on which an action is taken on a specific request.
Now, we have already seen that this HTTP request, an example dot com that came to the alb.
This will be associated with a listener one.
Now this listener one can be associated with certain set of rules sets.
Now, these set of rules can be defined by the user or the administrator based on which the action will
be performed.
For example, in this diagram, there are three rules.
So these rules are basically checking the contents of the request.
So first here is that it is checking if the user agent is Mozilla.
So whether it is coming from a Firefox browser for an example, it is checking if a host header is demo
dot com.
It is also checking if the path is videos.
So these are the three set of rules that are added to the listener.
Now, if this request matches one of these rules, it is not necessary that it needs to match all of
these rules, even if it matches one of the rules.
Next step is what will be the action that will be performed on this request.
For example, let's say this request matches the first rule, which is the user agent in this request
is Firefox.
So now what will your Elbe do?
This is where the rule actions comes into picture.
For example, if a request matches a specific rule, what actions you want to perform on that request
is determined in the rule action.
So as we are discussing, let's say the request matches the first rule, which is user agent is Mozilla.
So on that request there are multiple rule actions that are available.
You can forward these requests to a set of servers.
You can redirect that request to a specific domain or you can return a specific response back to the
client depending upon what you intend to do.
So let's quickly look into it.
Let's go back to our load balancer within our listeners.
I'll quickly click on view and edit rules.
All right.
Now within here, you see that there are a total of four rules that are available.
So these are the four listener rules where it is checking if the user agent is call, it is checking
if the user agent is Mozilla, it is checking if the user agent is W gate and if the request does not
match these three, then you have one more rule that determines what will happen to the set of requests
that does not match the first three rules.
So if you look into the first rule, which states if the request has the specific user agent header,
then so this then is basically the rule actions that we were determining.
So in here in this rule action, what we are doing, we are returning a fixed response and the response
is high alert.
So this is the rule action over here.
You also have one more request of Mozilla.
If you look into the rule action, it is returning a different set of response.
So this return fix response is nothing but the third.
All actions that we have seen over here.
All right.
Now, again, let's quickly try it out practically.
Just to revise.
So I'll copy the DNS name of our load balancer.
So from my terminal, if we do a call over here, we are getting a message.
Callers Hi, call if we perform a W gate on this specific load balancer.
And if we look into the index dot HTML, this time you are getting a specific response.
So this is where our rule actions comes into picture, where a specific rule is matching the load balancer
is performing a return fix response and in the return fixed response it is sending back message immediately.
The second important concept is the target group.
So a target group is used to root a request to one or more registered targets.
And these registered targets can be easy.
Two instances, lambda functions and so on.
For example, in this diagram there are two target group.
Target Group one is associated with 3c2 instance target group two is associated with a lambda function.
And what we can do is we can also associate a target group with a listener.
For example, if you look into the rule action, there is one rule action is forward two and this for
two allows us to forward the request to a specific target group.
So listener one is associated with target group one where there are two is C two instance.
Listener two is associated with Target Group two where there is one lambda function that is available.
So let's also quickly look into it.
Now within the load balancing section, you have a load balancers as well as the target group.
Now currently you have one target group that is available for today's demo.
Now if we look into this target group, if I open up the targets over here, you see there are two targets
available and these are nothing but the easy to instance targets that are associated with the target
group and from the load balancer.
Let's quickly look into the listener rules over here.
Within here, you can go ahead and add a rule.
Let's say if a condition matches, let's say if some request comes to the part of video, if you click
on Forward to within, you can specify the target group over here and this request will be forwarded
to the see two instances of lambda functions that are part of this target group.
All right.
So I hope with this at a high level overview, you understood the concept of listener and target groups.
Now, if you have understood this concept clearly, then creating a load balancer and its associated
complex configuration will become much more simpler for you.
So this will conclude today's video.