3
votes

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?

1
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

1 Answers

0
votes

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.