Amazon Elastic Load Balancer is not closing the connection to the server
As OP shared with his edit, the issue of connections not getting closed can be resolved with a change of load balancer type. This answer focuses on why this change has such an affect?
There seems to be an issue within Classic Load Balancer (ELB
). I've found the following posts with very similar issues;
- ELB - server keeps sending data to disconnected clients for hours
- Is there a way to lower the LBS KeepAlive?
- AWS ELB servlet client disconnection detection
It seems the issue stems from ELB
not being able to detect the client dropping from a connection. Especially when back-end is supplying some sort of data in a periodical manner, e.g. live audio stream, heartbeat, etc.
There doesn't seem to be a way to disable the keep-alive
setting of load balancers, yet, somehow, only with ELB
this trouble occurs.
I couldn't find exact feature that is creating this behavioural difference between ELB
& ALB
. I think the reason is either due to;
- Improved Health Checks in
ALB
, and/or - an internal structural difference that is not visible to us users, that somehow keeps this issue from happening on
ALB
I think the issue resolves when Application Load Balancer (ALB
) is used due to said improvements and it being much more flexible.
Check here for more on the differences between ELB
, ALB
, and NLB
ps. AWS support forums are terrible, all the good support & tips are paywalled and stored within PMs between them & their premium customers.