Ive been asked to look at adding a load balancer to one of our AWS environments.
The application servers which will sit behind the LB currently listen on ports anywhere in the tcp/6800-6999 range and can change frequently.
I did a few initial checks but when I go to configure an NLB, I am unable to pick a range of ports when configuring listeners. I could manually enter each port but this would take a long time and it got me thinking if the AWS NLB is the right tool for this job?
Had the same issue when i had to create ec2 with FTP server on it. Each of the pasv ports had to have its own target group and listener. Support said its the only way.
Thanks for the example. I think my scenario may be a bit different in that I need the LB to listen on all the ports from 6800-6999 and then send requests to one of several application servers also listening on 6800-6999.
Not sure a way around this in AWS but you could script this to do the heavy lifting for you, either just using a simple bash script using the AWS cli or using something like terraform.
Why exactly are you looking into setting this up? What does the backend look like, and by that I mean how many app server types are there? 5? 50? Do they absolutely require a range of ports?
Also, just to make sure you are aware of this, NLBs operate at Layer 4 of the OSI model and thus are capable of much higher performance, but at the cost of having quite a few of the ALB, which operates at Layer 7, features missing. If you haven’t already, you definitely need to check out the list of features each ELB type offers.
If you absolutely positively have to have a range of ports open due to say software architecture that simply cannot be altered right now, Terraform or CloudFormation to automate the drudgery of making all those rules is definitely what you need to look into. Depending on how these app servers work, as long as the performance of NLBs is not 100% required or other NLB unique offering, path or host based routing rules might also be worth looking into.
We use terraform, and even our method is a little bit of a hack. First we build the NLB’s and then we attach the listeners with a 2nd targeted apply, we really should figure out the proper “depends on” methodology.
NLBs as a service are a bit of a pain, and are just HAProxy configurations run by AWS. We have seen poorer performance under high loads from NLBs, than our own ec2 run HAProxies, so we reverted back to ec2’s in each AZ running HAProxy.
When you say that the ports change frequently, how/when/why do they change, and how do the clients participate in this change? NLB allows a modest number of listeners, and for the backed targets to all have different ports, but it’s all statically configured, and config changes take a minute or two to take effect, so if it has to change often and take effect quickly, it’s probably not a good fit.
The other issue is that the nature of these port changes might not be a fit for a general purpose load balancer at all. Without using a load balancer, when the application changes ports, how does a client who wants to connect to it know which port to use? Does it have to know about a different port for each host? Will any of that that still work when you slap a load balancer in front, which hides the individual identities of the servers?
Some additional context would help as to the need for frequent changes of ports on the listening side. However with what we have currently, have the following thoughts :
You could set up a server upstream of ELB & have it configured with ENI (depending on the amount of traffic) and forward incoming traffic to certain limited ports which is configured on ELB. You could use iptables to listen in on a range of ports and forward to one of the ports, say 6850 (provided your listening servers can still work), say as below:
Well when it’s a single EC2, there is, of course, another way: have the ports open on the internet and have people connect to the EC2 instance.
I’m not saying it’s what the Well-Architected Framework might recommend - but it might be a decent alternative if all the NLB is doing is pumping FTP packets to a single EC2 instance.