配置 Reliable Actors - KVSActorStateProviderConfiguring Reliable Actors--KVSActorStateProvider

通过更改 Microsoft Visual Studio 程序包根目录下的指定执行组件的 Config 文件夹中生成的 settings.xml 文件,可以修改 KVSActorStateProvider 的默认配置。You can modify the default configuration of KVSActorStateProvider by changing the settings.xml file that is generated in the Microsoft Visual Studio package root under the Config folder for the specified actor.

Azure Service Fabric 运行时在 settings.xml 文件中查找预定义的节名称,并在创建基础运行时组件时使用这些配置值。The Azure Service Fabric runtime looks for predefined section names in the settings.xml file and consumes the configuration values while creating the underlying runtime components.

备注

删除或修改 Visual Studio 解决方案中生成的 settings.xml 文件中的以下配置的节名称。Do not delete or modify the section names of the following configurations in the settings.xml file that is generated in the Visual Studio solution.

复制器安全配置Replicator security configuration

复制器安全配置用于保护复制过程中使用的通信通道的安全。Replicator security configurations are used to secure the communication channel that is used during replication. 这意味着服务无法看到对方的复制流量,从而确保高度可用的数据也处于安全状态。This means that services cannot see each other's replication traffic, ensuring that the data that is made highly available is also secure. 默认情况下,空的安全配置节会影响复制安全。By default, an empty security configuration section prevents replication security.

重要

在 Linux 节点上,证书必须是 PEM 格式。On Linux nodes, certificates must be PEM-formatted. 若要详细了解如何查找和配置适用于 Linux 的证书,请参阅在 Linux 上配置证书To learn more about locating and configuring certificates for Linux, see Configure certificates on Linux.

节名称Section name

<ActorName>ServiceReplicatorSecurityConfig<ActorName>ServiceReplicatorSecurityConfig

复制器配置Replicator configuration

复制器配置用于配置负责使执行组件状态提供程序状态高度可靠的复制器。Replicator configurations configure the replicator that is responsible for making the Actor State Provider state highly reliable. 默认配置由 Visual Studio 模板生成,应可满足要求。The default configuration is generated by the Visual Studio template and should suffice. 本部分介绍了可用于调整复制器的其他配置。This section talks about additional configurations that are available to tune the replicator.

节名称Section name

<ActorName>ServiceReplicatorConfig<ActorName>ServiceReplicatorConfig

配置名称Configuration names

名称Name 计价单位Unit 默认值Default value 备注Remarks
BatchAcknowledgementIntervalBatchAcknowledgementInterval Seconds 0.0150.015 收到操作后,向主要复制器发回确认之前,辅助复制器等待的时间段。Time period for which the replicator at the secondary waits after receiving an operation before sending back an acknowledgement to the primary. 为在此间隔内处理的操作发送的任何其他确认都作为响应发送。Any other acknowledgements to be sent for operations processed within this interval are sent as one response.
ReplicatorEndpointReplicatorEndpoint 不适用N/A 无默认值--必选参数No default--required parameter 主要/辅助复制器用于与副本集中其他复制器通信的 IP 地址和端口。IP address and port that the primary/secondary replicator will use to communicate with other replicators in the replica set. 这应该引用服务清单中的 TCP 资源终结点。This should reference a TCP resource endpoint in the service manifest. 若要详细了解如何在服务清单中定义终结点资源,请参阅服务清单资源Refer to Service manifest resources to read more about defining endpoint resources in the service manifest.
RetryIntervalRetryInterval Seconds 55 复制器未收到操作确认,重新传输消息之后的时间段。Time period after which the replicator re-transmits a message if it does not receive an acknowledgement for an operation.
MaxReplicationMessageSizeMaxReplicationMessageSize 字节Bytes 50 MB50 MB 可以在单个消息中传输的复制数据的最大大小。Maximum size of replication data that can be transmitted in a single message.
MaxPrimaryReplicationQueueSizeMaxPrimaryReplicationQueueSize 操作的数量Number of operations 10241024 主要队列中操作的最大数目。Maximum number of operations in the primary queue. 主复制器接收到来自所有辅助复制器的确认之后,释放一个操作。An operation is freed up after the primary replicator receives an acknowledgement from all the secondary replicators. 此值必须大于 64 和 2 的幂。This value must be greater than 64 and a power of 2.
MaxSecondaryReplicationQueueSizeMaxSecondaryReplicationQueueSize 操作的数量Number of operations 20482048 辅助队列中操作的最大数目。Maximum number of operations in the secondary queue. 会在使操作的状态在暂留期间高度可用后释放该操作。An operation is freed up after making its state highly available through persistence. 此值必须大于 64 和 2 的幂。This value must be greater than 64 and a power of 2.

存储配置Store configuration

存储配置用于配置本地存储,该存储用于保留正在复制的状态。Store configurations are used to configure the local store that is used to persist the state that is being replicated. 默认配置由 Visual Studio 模板生成,应可满足要求。The default configuration is generated by the Visual Studio template and should suffice. 本部分介绍了可用于调整本地存储的其他配置。This section talks about additional configurations that are available to tune the local store.

节名称Section name

<ActorName>ServiceLocalStoreConfig<ActorName>ServiceLocalStoreConfig

配置名称Configuration names

名称Name 计价单位Unit 默认值Default value 备注Remarks
MaxAsyncCommitDelayInMillisecondsMaxAsyncCommitDelayInMilliseconds 毫秒Milliseconds 200200 设置持久的本地存储提交的最大批处理间隔。Sets the maximum batching interval for durable local store commits.
MaxVerPagesMaxVerPages 页数Number of pages 1638416384 本地存储数据库中的最大版本页数。The maximum number of version pages in the local store database. 它确定未完成事务的最大数目。It determines the maximum number of outstanding transactions.

示例配置文件Sample configuration file

<?xml version="1.0" encoding="utf-8"?>
<Settings xmlns:xsd="https://www.w3.org/2001/XMLSchema" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2011/01/fabric">
   <Section Name="MyActorServiceReplicatorConfig">
      <Parameter Name="ReplicatorEndpoint" Value="MyActorServiceReplicatorEndpoint" />
      <Parameter Name="BatchAcknowledgementInterval" Value="0.05"/>
   </Section>
   <Section Name="MyActorServiceLocalStoreConfig">
      <Parameter Name="MaxVerPages" Value="8192" />
   </Section>
   <Section Name="MyActorServiceReplicatorSecurityConfig">
      <Parameter Name="CredentialType" Value="X509" />
      <Parameter Name="FindType" Value="FindByThumbprint" />
      <Parameter Name="FindValue" Value="9d c9 06 b1 69 dc 4f af fd 16 97 ac 78 1e 80 67 90 74 9d 2f" />
      <Parameter Name="StoreLocation" Value="LocalMachine" />
      <Parameter Name="StoreName" Value="My" />
      <Parameter Name="ProtectionLevel" Value="EncryptAndSign" />
      <Parameter Name="AllowedCommonNames" Value="My-Test-SAN1-Alice,My-Test-SAN1-Bob" />
   </Section>
</Settings>

备注Remarks

BatchAcknowledgementInterval 参数用于控制复制延迟。The BatchAcknowledgementInterval parameter controls replication latency. “0”值导致可能的最低延迟,但代价是牺牲吞吐量(因为必须发送和处理更多确认消息,每个包含较少的确认)。A value of '0' results in the lowest possible latency, at the cost of throughput (as more acknowledgement messages must be sent and processed, each containing fewer acknowledgements). BatchAcknowledgementInterval 的值越大,整体复制吞吐量就越高,但代价是会造成更高的操作延迟。The larger the value for BatchAcknowledgementInterval, the higher the overall replication throughput, at the cost of higher operation latency. 这直接转换为事务提交的延迟。This directly translates to the latency of transaction commits.