I am exploring how to implement distributed collections for objects in Orleans. I imagine this functionality could be useful for a few scenarios, e.g.
So far I have identified the following main goals important for my Orleans-based project:
I implemented a prototype with some very limited functionality of distributed collections and would be happy to discuss its approaches [1].
I would like to hear what your requirements for a distributed collection are. Is it interesting to you to deal with not only collections of grains but collections of plain old objects as well? Do you care about consistency a lot?
Deprecated [1] https://github.com/bwanner/Orleans.Collections
[2] Related issue: https://github.com/dotnet/orleans/issues/602
Update: See https://github.com/dotnet/orleans/issues/1412#issuecomment-193702118 for latest update on concept and implementation status.
Benjamin terrific! Would love to see it in action. When you feel comfortable you can make a PR here. Thanks
Related work Orleans.Consensus. Cross-referencing https://github.com/dotnet/orleans/issues/447 and https://github.com/dotnet/orleans/issues/446 for some ideas on silo locality (of these, don't pay attention to all that is written in #446 and the issue from which it stems from).
@bwanner , I think it is definitely an interesting idea. We generally like designs that built on top of Orleans (stack design). Our internal stream pub-sub is built this way, Orleans.Consensus, Orleans.Activities and more.
I would start with supporting some simple collections, like DistbutedDictionary, where you can lookup the key not by scanning all partitioning but by directly routing to the right one. The routing can be either done via static mapping (hash based or range based), or via intermediate routing grain.
Same with List.
https://github.com/OrleansContrib would be a good place to host it initially. As others will start using it, you will get more concrete feedback and will be able to evolve the model.
I would say that the key thing is to have at least one concrete usage scenario, and build the system targeting at least one production usage (while of course still not losing the sight of generality).
Added a prototypical implementation of containers to OrleansContrib/Orleans.Containers.
Moved away from the collection term a bit and introduced the notion of containers:
A container serves as storage for an object and has the responsibility of executing functions on that object. If one adds an object to a container it becomes the object's owned and returns a ContainerHostedElement<T>. This reference can be used to access that object within the container.
This concept different to regular C# collections where collections are just storing a reference to an object and the object is located on the globally accessible heap. Also C# collections are supposed to implement IEnumerable which is not a concept necessarily aligned with Orleans principles.
The project is not documented well, but the examples should give a feeling for what it is trying to achieve. Feedback is highly appreciated :)
Have you considered the use of IAsyncEnumerable?
I'm new to Orleans and am trying to work out how to deal with collections of grains e.g. A UserGrain may contain many BlogPostGrain's and this requires filtering, sorting, paging, searching. What is the recommended approach?
Most helpful comment
Have you considered the use of
IAsyncEnumerable?I'm new to Orleans and am trying to work out how to deal with collections of grains e.g. A UserGrain may contain many BlogPostGrain's and this requires filtering, sorting, paging, searching. What is the recommended approach?