问题
I have n Endpoints behind an AWS Elastic Load Balancer, and I want to make a REST Call to everyone of those machines. If I make this call directly to the ELB, it will call just one of the machines. So my question is there a way yo make it? Maybe a specific AWS ELB Api that I can use, or some configuration I don't know. Before you suggest: I can not change the REST to anything else, I have no control over the application.
回答1:
You'll have to bypass the load balancer to do this. You could write something to query the AWS API for all the instances connected to the load balancer and get their external IP addresses, and then call the REST endpoint on each machine.
Also, the machines behind the load balancer would need a security group configuration that allows you to send requests to them without going through the load balancer.
Are these instances in an Auto Scaling group? If an auto scaling event occurs while you are in the middle of calling these REST endpoints you could either end up having some requests fail, or you could end up missing the REST call on any new instances.
Obviously there are much more elegant ways to handle this sort of communication to multiple instances, but you would need to be able to modify the code running on those instances.
来源:https://stackoverflow.com/questions/32701738/send-a-request-to-all-machines-behind-an-aws-elb