Kiryl
Kiryl

Reputation: 1511

Can't report load for the metrics in Actors Service

There is a nice feature in Service Fabric that allows each service object to update its own load during runtime. Dynamic load reports allow replicas or instances to adjust their allocation/reported load of metrics over their lifetime. Here is how I can do this within a service:

this.Partition.ReportLoad(new List<LoadMetric> { new LoadMetric("MemoryInMb", 1234)});

The problem is that Partition is a protected property that is declared in StatefulServiceBase, so it's available in ActorService but not in Actor. I mean, I can't do Actor.ActorService.Partition.ReportLoad(...). I do see a workaround where I could create my custom actor service class and make this property public, but I'm wondering if it makes sense and was there any particular reason to not being able to report the load in Actors?

Upvotes: 0

Views: 238

Answers (1)

LoekD
LoekD

Reputation: 11470

ActorService does derive from StatefulServiceBase. You should be good to go.

See this: https://learn.microsoft.com/en-us/dotnet/api/microsoft.servicefabric.actors.runtime.actorservice?redirectedfrom=MSDN#microsoft_servicefabric_actors_runtime_actorservice


edit: What load metric do you have that's specific to one Actor instance?

Actors usually have a limited lifespan. Load reporting is a periodic process. Those two don't really combine well. Yes, you could use ActorReminders, but why use them when you have an ActorService that can do the same thing without the limitations?

Upvotes: 1

Related Questions