Service Fabric 服务的可用性Availability of Service Fabric services
本文概述 Azure Service Fabric 服务如何保持服务的可用性。This article gives an overview of how Azure Service Fabric maintains the availability of a service.
Service Fabric 无状态服务的可用性Availability of Service Fabric stateless services
Service Fabric 服务可以是有状态服务，也可以是无状态服务。Service Fabric services can be either stateful or stateless. 无状态服务是不具备需要具有高可用性和可靠性的本地状态的应用程序服务。A stateless service is an application service that does not have a local state that needs to be highly available or reliable.
InstanceCount。Creating a stateless service requires defining an
InstanceCount. 实例计数定义应在群集中运行的无状态服务应用程序逻辑的实例数。The instance count defines the number of instances of the stateless service's application logic that should be running in the cluster. 建议通过增加实例数来扩大无状态服务。Increasing the number of instances is the recommended way of scaling out a stateless service.
无状态命名服务的实例发生故障时，都会在群集中某个符合条件的节点上创建一个新实例。When an instance of a stateless named-service fails, a new instance is created on an eligible node in the cluster. 例如，无状态服务实例可能会在 Node1 上发生故障，但可以在 Node5 上进行重建。For example, a stateless service instance might fail on Node1 and be re-created on Node5.
Service Fabric 有状态服务的可用性Availability of Service Fabric stateful services
有状态服务具备与之关联的状态。A stateful service has a state associated with it. 在 Service Fabric 中，有状态服务均建模为副本集。In Service Fabric, a stateful service is modeled as a set of replicas. 每个副本是服务的代码的运行实例。Each replica is a running instance of the code of the service. 此副本还拥有该服务的状态的副本。The replica also has a copy of the state for that service. 在一个副本（以下称为“主副本” ）上执行读取和写入操作。Read and write operations are performed at one replica, called the Primary. 因写入操作发生的状态更改会复制 到副本集的其他副本（以下称为活动次要副本 ），并进行应用。Changes to state from write operations are replicated to the other replicas in the replica set, called Active Secondaries, and applied.
只能有一个主要副本，但可以有多个活动次要副本。There can be only one Primary replica, but there can be multiple Active Secondary replicas. 可以配置活动辅助副本的数目，而副本数越多，可容忍的并发软件和硬件故障数越多。The number of active Secondary replicas is configurable, and a higher number of replicas can tolerate a greater number of concurrent software and hardware failures.
如果主要副本不可用，Service Fabric 会指定一个活动次要副本成为新的主要副本。If the Primary replica goes down, Service Fabric makes one of the Active Secondary replicas the new Primary replica. 此活动辅助副本具有最新的状态（通过复制 ）并且可以继续处理更多的读取/写入操作。This Active Secondary replica already has the updated version of the state, via replication, and it can continue processing further read/write operations. 此过程称为“重新配置” ，并在重新配置一文中作了进一步介绍。This process is known as reconfiguration and is described further in the Reconfiguration article.
主副本和活动辅助副本的这一概念称为副本角色 。The concept of a replica being either a Primary or Active Secondary, is known as the replica role. 这些副本在副本和实例一文中作了进一步介绍。These replicas are described further in the Replicas and instances article.
有关 Service Fabric 概念的详细信息，请参阅以下文章：For more information on Service Fabric concepts, see the following articles: