I am trying to restrict maximal number of TCP connections from amazon NLB to a target group. Example of a desired scenario:
We have 2 instances and NLB. The first 100 users with 100 TCP connections are directed to the first instance and are connected for 1 hour. During this hour another 100 users connect to NLB and are directed to the second instance. The user number 201 is not allowed to connect.
I have not found any metric on NLB or autoscaling group which can allow restriction by conenction number. Is it possible with NLB?
Nope, that's not possible. You could try and trigger AutoScaling, but its not going to be instant. If you need that kind of custom logic you'd need to use a 3rd party solution to act as a load balancer, like HAProxy or NGINX