3

I have a set of user-specific stateful services servicing requests forwarded from a public-facing stateless service (web API) in an app.

I'm trying to delete a stateful service if it has not serviced any user request since a given time interval, say an hour. Currently, I'm managing this by keeping a .NET timer in the service itself and using the tick event to self-destruct the service if it's been idle.

Is this the right way to do it? Or is there any other more efficient approach to do this in Azure service fabric?

zrvr
  • 105
  • 5
  • 2
    It reads like you might be able to use the Actor model here. They will automatically be garbage-collected when they become idle after some time. – LoekD May 05 '17 at 07:18

1 Answers1

0

The mechanism you have will work great and is what we'd normally recommend.

Another way to do it would be to have a general "service manager" service that periodically checked to see if services were busy, (or were informed) and which could kick off the deleteserviceasync call. That way only that service would need the cluster admin rights, while all the others could get locked down to read only.

masnider
  • 2,609
  • 13
  • 20
  • How would the service manager check if services are busy? are there any recommendations for that? – Kayani Oct 31 '18 at 06:21
  • Not really any one answer. Ping an endpoint on the service over http, have the service report back to the service manager when it is done, have the service manager look at some third piece of data that indicates the worker is done (database field last written time, aggregated performance counters, trace activity, whatever). – masnider Nov 05 '18 at 19:36