2

I have a stateless service fabric service which basically does a batch processing at specified time interval. So having multiple instances would complicate things as each instance would try to do the same batch job.

I strictly want to run a single batch process. Currently I have set the InstanceCount of this service to 1 in ApplicationManifest.xml. What will happen if there are multiple nodes? Would I still have single instance of this service? or how do I make sure this service has single instance regardless or number of Nodes/Partitions?

Kurubaran
  • 8,696
  • 5
  • 43
  • 65

1 Answers1

2

Currently I have set the InstanceCount of this service to 1 in ApplicationManifest.xml. What will happen if there are multiple nodes? Would I still have single instance of this service?

If there are multiple nodes only one will contain the primary, active instance. Other nodes may host replica's that will take over when needed, for example when the node where the primary instance lives goes down.

how do I make sure this service has single instance regardless or number of Nodes/Partitions?

We have covered multiple nodes in the first part of the answer. Regarding partitions: stateless services only have 1 partition so it does not play a role regarding to your question.

For more background material read the docs about the service lifecycle and about replica lifecycles

Peter Bons
  • 26,826
  • 4
  • 50
  • 74
  • Thank you for your explanation. Is there any chance that primary instance and replicas can be active concurrently? In my case, I see batch processing is done more than once at specific time interval. So wondering if it's due to multiple instances. – Kurubaran May 01 '19 at 08:04
  • 2
    No it should not. Is your code located in the `RunAsync` and do you respect the cancelationtoken? Otherwise add some logging that logs invocation of run together with the instance id. – Peter Bons May 01 '19 at 08:27
  • Thanks again. yes code is within RunAsync and haven't used cancellation token. I just logged instance Id, lets see what happens. – Kurubaran May 01 '19 at 14:15