简体   繁体   English

扩展Azure服务结构无状态服务

[英]Scaling of Azure service fabric Stateless services

Can you please give me a better understanding of how we can scale the stateless services without partitioning? 您能否让我更好地了解我们如何在不分区的情况下扩展无状态服务?

Say we have 5 nodes in a cluster and we have 5 instances of the service. 假设我们在集群中有5个节点,并且有5个服务实例。 On simple testing a node is behaving as sticky where all the requests I am sending are being served by only one node. 在简单测试中,一个节点表现为粘性,其中我发送的所有请求仅由一个节点提供服务。 In the scenario when we have high volume of requests that come in, can other instances be automatically used to serve the traffic. 在出现大量请求的情况下,可以自动使用其他实例来提供流量。 How do we handle such scale out situations in service fabric? 我们如何处理服务架构中的此类横向扩展情况?

Thanks! 谢谢!

Usually there's no need to use partitioning for stateless SF services, so avoid that if you can: 通常,对于无状态SF服务,无需使用分区,因此如果可以,请避免这样做:

more on SF partitioning, including why its not normally used for stateless services 有关SF分区的更多信息,包括为何通常不将其用于无状态服务

If you're using the ServiceProxy API, it will maintain sticky connections to a given physical node in the cluster. 如果您使用的是ServiceProxy API,它将与群集中的给定物理节点保持粘性连接。 If you're (say) exposing HTTP endpoints, you'll have one for each physical instance in the cluster (meaning you'll end up talking to one at a time, unless you manually cycle thru them). 如果(例如)公开HTTP端点,则群集中的每个物理实例都将拥有一个(这意味着您最终一次只能与一个端点进行对话,除非您手动循环通过它们)。 You can avoid this by: 您可以通过以下方式避免这种情况:

  1. Creating a new proxy instance for each call, which tends to be expensive if you do it alot (or manually cycle thru the list of instance endpoint URLs, which can be tedious and/or expensive) 为每个调用创建一个新的代理实例,如果您进行大量操作(或者手动循环遍历实例端点URL的列表,这可能会很繁琐和/或昂贵),这往往会很昂贵。

  2. Put a load balancer in front of your cluster and configure all traffic from your clients to SF nodes to be forwarded thru that. 将负载平衡器放在群集的前面,并配置从客户端到SF节点的所有流量都将通过该流量转发。 The load balancer can be configured for Round-Robin, etc. style semantics: 可以为Round-Robin等样式语义配置负载均衡器:

Azure Load Balancer Azure负载平衡器

Azure Traffic Manager Azure交通管理器

Good luck! 祝好运!

You can query the request using the reverse proxy installed on each node. 您可以使用每个节点上安装的反向代理查询请求。 Using the https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-reverseproxy 使用https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-reverseproxy

The reverse proxy then resolve the endpoint for you. 反向代理然后为您解析端点。 If you have multiple instances of the a stateless service then it will forward your request to a random one. 如果您有无状态服务的多个实例,那么它将把您的请求转发给随机的一个。

If during heavy load you can increase the instance count of your service and the proxy then include the new instances automatically. 如果您在繁重的工作期间可以增加服务的实例数量,然后代理将自动包括新实例。

I will assume you are calling your services from outside your cluster. 我假设您正在从群集外部调用服务。 If yes, your problem is not specific for Service Fabric, it is Azure VMSS + LB. 如果是,则您的问题并非特定于Service Fabric,而是Azure VMSS +LB。

Service Fabric runs on top of Virtual Machines Scale Set, these VMs are created behind a Load Balancer, when the client connects to your service, they are creating a connection through the load balancer to your service, whenever a connection is open, the load balancer assign one target VM for handling your request, and any request made from your client, while using the same connection(keep alive), will be handled by the same node, this is why your load goes to a single node. Service Fabric在虚拟机规模集之上运行,这些VM在负载均衡器之后创建,当客户端连接到您的服务时,它们通过负载均衡器与您的服务建立连接,只要打开了连接,负载均衡器分配一个目标VM来处理您的请求,并且使用相同的连接(保持活动状态)时,来自客户端的任何请求都将由同一节点处理,这就是为什么您的负载转到单个节点的原因。

LB won't round robin the requests because they are using the same connection, it is a limitation(feature) of the LB, to work around this problem, you should open multiple connections or use multiple clients(instances). LB不会舍入请求,因为它们使用的是同一连接,这是LB的限制(功能),要变通解决此问题,您应该打开多个连接或使用多个客户端(实例)。

This is for default distribution mode(Hash-based). 这是默认分发模式(基于哈希)的。 You have to check also the routing rules in the LB to check if the distribution mode is Hash-based (5 tuple= ip+port) or if it is IP affinity mode (ip only), otherwise multiple connections from same IP will still be linked to same node. 您还必须检查LB中的路由规则,以检查分发模式是基于哈希 (5元组= ip + port)还是IP亲和模式 (仅ip),否则来自同一IP的多个连接仍然会链接到同一节点。

Source: Azure Load Balaner Distribution Mode 来源: Azure负载平衡器分发模式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM