问题
Can multiple role instances of the same role can talk to each other by obtaining VIP (Virtual IP) address for a specific endpoint listened by all those instances from RoleEnvironment
? If so, is returned VIP can be load balanced to the caller (of RoleEnvironment
methods) instance itself.
回答1:
Role instances can talk to each other via internal endpoints. Unlike input endpoints, they are only visible to other instances within a deployment (regardless of the role).
Talking directly, via internal endpoint, bypasses the external-VIP load balancer completely. So, if you have three worker role instances that you're trying to connect to (say that's where your REST service resides), you'd have to do your own load-balancing across the 3 instances.
Working with internal endpoints is just as straightforward as input endpoints. First set one up:
Then grab one at random. For example (by the crudest sense of the word):
var random = new Random();
var role = RoleEnvironment.Roles["WorkerRole1"];
var instanceNumber = random.Next() % role.Instances.Count;
var ipendpoint = role.Instances[instanceNumber].InstanceEndpoints["myservice"].IPEndpoint;
var address = ipendpoint.Address;
var port = ipendpoint.Port;
Note: You can still reach out to an input endpoint on any role, from any role. At that point, you'll be load-balanced just like any other traffic coming from the outside world. And you'll have to worry about security as well (whereas with internal endpoints you don't).
来源:https://stackoverflow.com/questions/16323767/azure-network-communication-between-instances-of-the-same-role