I'm working on a Stateful Service that manages inventory for a bunch of products for our customers. Each customer belongs to a tenant group which may have an instance of this stateful service in his own partition. So a tenant with Id 10 and a tenant with Id 11 may be in a same partition (let's assume).
Each tenant has access to Inventory for an Item with Id = 100 (for example). Each time a person wants to purchase this item, I check if the Inventory exists for this tenant, if not, I notify the calling application (a Reliable Actor in this case) and let him know.
However, I've noticed that I was storing a reliable dictionary with the Key of the Item Id and the inventory counts. I noticed that even though the services belong to separate partitions, they still accessed the same object. Is this true that even though these services reside under different partitions, that they still have the same underlying state?
If so, would it make more sense to store this information directly at the Actor level? I didn't see reliable collections at the actor level and thus I built a Stateful Service that would be invoked by an Actor but in my prior Akka implementations, I would store this state at the Actor level.
I'm curious if anyone has implemented something similar and could shed light on this.
Thank You in advance for your responses!
Anup Marwadi
No, state is not shared between different partitions. That would defeat the purpose; keeping a large dataset manageable by dividing it.
Consider implementing multi-tenancy by creating an Application instance per tenant. This way there will never be any sharing of data between tenants, and you can backup/on-/off-board tenants easily.
This article explains service partitions very well.