Proposal: Change the way StatelessWorkers are activated
Currently, a grain marked as a StatelessWorker will do a round-robin instantiation of grains to handle the incoming requests. It will keep creating instances of grains until the max level is reached. In most cases this is not ideal in terms of performance and memory usage (especially if you cache data in a local stateless-worker).
I have a WIP PR coming on this (I am not a previous contributor to Orleans in the core, so please be gentle and somewhat thorough looking at my suggestions). :)
The PR implements creating activations when the activations that are already busy have an incoming request queue. This makes it so that there are fewer activations in the silo while still keeping things local.
There are added tests implementing this with locking access to the grain activation with a semaphore to force multiple activations and one that awaits all calls showing that they are all routed to the same activation.
We're moving this issue to the 4.0-Planning milestone for future evaluation / consideration. Because it's not immediately obvious that this is a bug in our framework, we would like to keep this around to collect more feedback, which can later help us determine the impact of it. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.