【问题标题】:Azure how to create an internal endpoint that has load ballancing?Azure 如何创建具有负载平衡的内部端点?
【发布时间】:2010-12-26 15:02:11
【问题描述】:

Web 角色或辅助角色的内部端点如何实现负载平衡?如果我将 ServiceDefinition.csdef 中的端点声明为 <InternalEndpoint name="GeneratePDF" protocol="tcp" /> ,然后我将其公开为:

// define an internal endpoint for inter-role traffic
  RoleInstanceEndpoint internalEndPoint =
      RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["IGeneratePDF"];
  this.serviceHost.AddServiceEndpoint(
     typeof(IGeneratePDF),
     binding,
     String.Format("net.tcp://{0}/GeneratePDF", internalEndPoint.IPEndpoint));

然后我得到一个端点,允许我调用我想要的每个实例。但是我没有以这种方式获得负载平衡,这正是我想要的。

【问题讨论】:

    标签: endpoint


    【解决方案1】:

    可能不是理想的解决方案,但这似乎是一种方法......

        int instances = RoleEnvironment.Roles["InstanceName"].Instances.Count;
        Random rand = new Random();
        var endpoint = RoleEnvironment.Roles["InstanceName"].Instances[rand.Next(instances)].InstanceEndpoints["YourEndpointName"].IPEndpoint;
    

    根据我正在阅读的内容,实例列表中只有工作角色(标记为就绪的角色),因此您应该只获取正在工作的实例...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-20
      相关资源
      最近更新 更多