Search code examples
c#azure-service-fabricservice-fabric-stateless

Settings for multiple partitions, multiple node for service fabric stateless service


With current situation of using stateless services, to prevent loss of connection the required design is using primary instance running in every node (Currently set to use 5 nodes) and hopefully each primary running in every node helps endpoint not error out due to connection loss. (In this case, SignalR)

So the design would be: Single primary and 4 replicas in each partition total 5 partitions running in 5 nodes.

This should have been a straightforward configuration setting, but turns out tricky to accomplish due to lack of thorough manuals with example code.

So far, what I have found out is:

Setting DefaultValue="-1" for the Service instance count achieves the service to run in every node but you still need it to be in combination with one of the followings:

SingletonPartition or UniformInt64Partition or NamedPartition

SingletonPartition is the default in Stateless service and combination of DefaultValue "-1" with SingletonPartition forces the service run on only one node, which beats the purpose of using multiple nodes.

So I tried something like: StatelessService InstanceCount="5" (Should this be 25 including replicas?) UniformInt64Partition PartitionCount="5" lowKey="0" highkey="5" (Should the highkey be 24 to include all the replicas?)

Some link says lowkey and highkey should match number of partitions and another link seemingly including all the instances including replicas.

I am still not successful in achieving 5 partitions, 5 nodes and each parition running primary service..


Solution

    • For stateless services, with singleton partitions setting instance count to -1 means 'run one on every node'.
    • For stateless services, you don't use Replicas but Instances. Replicas are for replication of state.

    So, use the singleton partition and set instance count to -1.