Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orleans 7.x does not support multiple stateless worker grain types with different StatelessWorkerPlacement.MaxLocal values #8873

Closed
isaachili opened this issue Feb 22, 2024 · 1 comment · Fixed by #8885

Comments

@isaachili
Copy link

isaachili commented Feb 22, 2024

We have observed that under load, the value provided to the maxLocalWorkers parameter in the StatelessWorkerAttribute constructor does not get respected at times. In such situations, StatelessWorkerPlacement.MaxLocal is getting set to DefaultMaxStatelessWorkers.

This behaviour was reproduced on multi-node and single-node clusters alike, whereby the stateless worker is being constrained to a maximum of 1 stateless worker per silo as per the following code:

[StatelessWorker(1)]
public class FooGrain : Grain, IFooGrain
{	
}

Whilst debugging Orleans code, we noticed that the initial stateless worker grain gets created via StatelessWorkerGrainContext.cs#L185. StatelessWorkerGrainContext.CreateWorker(object) gets invoked a second time, this time by StatelessWorkerGrainContext.cs#L216 due to _workers.Count being less than _maxWorkers, which holds a value of 8 (number of logical cores) instead of 1.

Furthermore, when the GrainTypeSharedContext constructor is invoked, the PlacementStrategy property is being set to a StatelessWorkerPlacement instance with a MaxLocal of 1.

@ghost ghost added the Needs: triage 🔍 label Feb 22, 2024
@isaachili
Copy link
Author

I have noticed that this happens whenever there are different stateless worker grain types with different stateless worker count limits.

[StatelessWorker(1)]
public class SingleStatelessWorkerGrain : Grain, ISingleStatelessWorkerGrain
{	
}

[StatelessWorker]
public class MultipleStatelessWorkerGrain : Grain, IMultipleStatelessWorkerGrain
{	
}

It seems that the PlacementStrategy used by StatelessWorkerGrainContext is the same instance for both SingleStatelessWorkerGrain and MultipleStatelessWorkerGrain, even though the two grain types have different StatelessWorker attributes, with different MaxLocal values.

@isaachili isaachili changed the title Stateless worker grains do not respect StatelessWorkerAttribute's maxLocalWorkers parameter in Orleans 7.x Orleans 7.x does not support multiple stateless worker grain types with different StatelessWorkerPlacement.MaxLocal values Feb 22, 2024
ReubenBond added a commit to ReubenBond/orleans that referenced this issue Feb 27, 2024
ReubenBond added a commit to ReubenBond/orleans that referenced this issue Feb 28, 2024
ReubenBond added a commit to ReubenBond/orleans that referenced this issue Mar 7, 2024
ReubenBond added a commit that referenced this issue Mar 7, 2024
…8885)

* Fix #8873 StatelessWorker MaxLocal property not being correctly accounted for
@github-actions github-actions bot locked and limited conversation to collaborators Apr 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant