So now let's talk about a feature
that can come up in the exam,
which is called Connection Draining.
So it has two names, actually.
If you're using a Classic Load Balancer,
it is called Connection Draining,
but if you're using an Application Balancer
or a Network Load Balancer,
this is called a Deregistration Delay.
And the idea behind this concept is that
it will give some time for your instances
to complete the inflight request or the active request
while the instance is being deregistered
or marked unhealthy.
And once a connection is being drained,
so once an instance is being drained,
then the ELB will stop sending your request
to the EC2 instance that is being drained
while being deregistered.
So let's have a look at a diagram to understand better.
So we have three EC2 instances
and in one of them we'll set it in draining mode.
So the users that are already connected to that EC2 instance
are going to be given enough time,
which is the draining period, okay,
to complete their existing connection
and to complete their existing request.
And then once everything's done,
then all the connections will be shut down.
Now, if new users try to connect to our ELB,
our ELB is smart enough to know
that because our EC2 instance is in draining state,
then it will only establish new connections
with other EC2 instances, for example,
my second EC2 instance or my third EC2 instance.
Now you can parametrize
these Connection Draining parameters.
So you can set it anywhere between 1 to 3,600 seconds.
By default, it is 300 seconds, so five minutes,
and you can disable it altogether
if you set the value to zero,
which means that there's no draining happening.
Now, if you set it to low value, okay, this is good
if your requests are short, for example, if there were very,
very short requests for, let's say, less than one second,
well, it's a good idea to set
the draining connection parameter to maybe 30 seconds, okay,
because then this will allow your EC2 instance
to be drained really fast and then be taken offline,
maybe to be replaced or something like this.
If your request can be quite long, for example,
if you have uploads or long lived requests,
then you want to set it to something pretty high,
but the trade-off is that's your EC2 instance
is not going to go away as soon as soon as possible, okay,
it's going to have to wait
until this Connection Draining period is done, okay?
So this is what you need to know about this setting
at a high level.
I hope you liked it and I will see you in the next lecture.