缩放 Service Fabric 独立群集Scaling Service Fabric standalone clusters

Service Fabric 群集是一组通过网络连接在一起的虚拟机或物理计算机,微服务会在其中部署和管理。A Service Fabric cluster is a network-connected set of virtual or physical machines into which your microservices are deployed and managed. 属于群集一部分的计算机或 VM 称为节点。A machine or VM that's part of a cluster is called a node. 群集可以包含数千个节点。Clusters can contain potentially thousands of nodes. 创建 Service Fabric 群集后,可以群集横向缩放(更改节点数)或纵向缩放(更改节点资源)该群集。After creating a Service Fabric cluster, you can scale the cluster horizontally (change the number of nodes) or vertically (change the resources of the nodes). 随时可以缩放群集,即使该群集上正在运行工作负荷。You can scale the cluster at any time, even when workloads are running on the cluster. 在缩放群集的同时,应用程序也会随之自动缩放。As the cluster scales, your applications automatically scale as well.

为何缩放群集?Why scale the cluster? 应用程序的需求会不断变化。Application demands change over time. 可能需要增加群集资源来满足更多的应用程序工作负荷或网络流量,或者在需求下降时减少群集资源。You may need to increase cluster resources to meet increased application workload or network traffic or decrease cluster resources when demand drops.

横向扩展和缩减Scaling in and out, or horizontal scaling

更改群集中的节点数。Changes the number of nodes in the cluster. 新节点加入群集后,群集资源管理器会将服务移到其中,导致现有节点上的总负载减少。Once the new nodes join the cluster, the Cluster Resource Manager moves services to them which reduces load on the existing nodes. 此外,如果群集的资源未被有效利用,可以减少节点数量。You can also decrease the number of nodes if the cluster's resources are not being used efficiently. 节点退出群集后,服务会移出这些节点,剩余节点上的负载会增大。As nodes leave the cluster, services move off those nodes and load increases on the remaining nodes. 减少 Azure 中运行的群集的节点数可以节省资金,因为我们是根据 VM 的数量付费,而不是根据这些 VM 上的工作负荷付费。Reducing the number of nodes in a cluster running in Azure can save you money, since you pay for the number of VMs you use and not the workload on those VMs.

  • 优势:理论上无限缩放。Advantages: Infinite scale, in theory. 如果应用程序采用可伸缩性设计,则可以通过添加更多节点来实现无限扩充。If your application is designed for scalability, you can enable limitless growth by adding more nodes. 使用云环境中的工具可以轻松添加或删除节点,因此可以方便地调整容量,并且只需为使用的资源付费。The tooling in cloud environments makes it easy to add or remove nodes, so it's easy to adjust capacity and you only pay for the resources you use.
  • 劣势:应用程序必须采用可伸缩性设计Disadvantages: Applications must be designed for scalability. 应用程序数据库和持久性可能需要更多的体系结构工作才能正常缩放。Application databases and persistence may require additional architectural work to scale as well. 但是,Service Fabric 有状态服务中的可靠集合能够大大简化应用程序数据的缩放。Reliable collections in Service Fabric stateful services, however, make it much easier to scale your application data.

独立群集允许在本地或所选的云提供程序中部署 Service Fabric 群集。Standalone clusters allow you to deploy Service Fabric cluster on-premises or in the cloud provider of your choice. 节点类型由物理机或虚拟机构成,具体取决于部署。Node types are comprised of physical machines or virtual machines, depending on your deployment. 与 Azure 中运行的群集相比,缩放独立群集的过程牵涉到的工作要略多一些。Compared to clusters running in Azure, the process of scaling a standalone cluster is a little more involved. 必须手动更改群集中的节点数,然后运行群集配置升级。You must manually change the number of nodes in the cluster and then run a cluster configuration upgrade.

删除可能启动多个升级的节点。Removal of nodes may initiate multiple upgrades. 某些节点标有 IsSeedNode="true" 标记,可使用 Get-ServiceFabricClusterManifest 通过查询群集清单进行标识。Some nodes are marked with IsSeedNode="true" tag and can be identified by querying the cluster manifest using Get-ServiceFabricClusterManifest. 在此类方案中,因为种子节点需要移动,因此删除此类节点相比其他节点需要较长时间。Removal of such nodes may take longer than others since the seed nodes will have to be moved around in such scenarios. 群集必须至少维护三个主节点类型的节点。The cluster must maintain a minimum of three primary node type nodes.


我们建议你不要将节点数降低到群集的可靠性层的群集大小以下。We recommend that you do not lower the node count below the Cluster Size of the Reliability Tier for the cluster. 这会干扰 Service Fabric 系统服务在群集中复制的能力,并且会破坏群集的稳定性或可能销毁群集。This will interfere with the ability of the Service Fabric System Services to be replicated across the cluster, and will destabilize or possibly destroy the cluster.

缩放独立群集时,请记住以下准则:When scaling a standalone cluster, keep the following guidelines in mind:

  • 应逐个节点地替换主节点,而不是批量删除再添加。The replacement of primary nodes should be performed one node after another, instead of removing and then adding in batches.
  • 删除节点类型之前,请检查是否存在任何引用该节点类型的节点。Before removing a node type, check if there are any nodes referencing the node type. 请在删除相应节点类型之前删除这些节点。Remove these nodes before removing the corresponding node type. 删除所有相应节点后,可从群集配置中删除节点类型并使用 Start-ServiceFabricClusterConfigurationUpgrade 开始配置升级。Once all corresponding nodes are removed, you can remove the NodeType from the cluster configuration and begin a configuration upgrade using Start-ServiceFabricClusterConfigurationUpgrade.

有关详细信息,请参阅缩放独立群集For more information, see scale a standalone cluster.

纵向扩展和缩减Scaling up and down, or vertical scaling

更改群集中节点的资源(CPU、内存或存储)。Changes the resources (CPU, memory, or storage) of nodes in the cluster.

  • 优势:软件和应用程序体系结构保持不变。Advantages: Software and application architecture stays the same.
  • 劣势:有限缩放,因为在单个节点上增加的资源量有限制。Disadvantages: Finite scale, since there is a limit to how much you can increase resources on individual nodes. 会造成停机,因为需要使物理机或虚拟机脱机才能添加或删除资源。Downtime, because you will need to take physical or virtual machines offline in order to add or remove resources.

后续步骤Next steps