Azure network communication between instances of the same role

筅森魡賤 提交于 2019-12-10 10:31:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!