Streams - Azure Queues - stream mapping only takes into account GUID
In regards to this method (and the subsequent method call into HashRing):
https://github.com/dotnet/orleans/blob/8d6153f46763a3ec97db483142ce17b9d90dc9c9/src/Orleans/Streams/QueueAdapters/HashRingBasedStreamQueueMapper.cs#L46
Should the mapping take into account the namespace of the stream as well?
The reason I ask is that in our current implementation we use a tenant ID/GUID for the stream GUID and then have many namespaces (e.g. per event namespacing) and this causes all messages for a given tenant to end up in a single queue. If in turn a certain tenant is under high load, the pulling agent responsible for the queue appears to get saturated ("Stream cache is under pressure. Backing off.") and it eventually stops/halts processing queues messages (the only way to get the messages to get picked up again has been to restart the associated silo so that a different pulling agent takes responsibility for the queue).
Having the messages spread across the total number of queues would seemingly help to alleviate this issue. Thoughts?
Should the mapping take into account the namespace of the stream as well?
streamGuid is designed to be the unique Id for a stream, using it is supposed to be enough to identity one stream, not multiple ones. StreamNameSpace is introduced to support implicit subscribing, it is like a metadata field in streamIdentity. But it isn't currently designed to support uniqueness of a stream, if this make any sense.
Having the messages spread across the total number of queues would seemingly help to alleviate this issue. Thoughts?
Stream namespace is introduced to support implicit subscribing. I don't think using it to spread messages across queues is the intended usage. And it doesn't guarantee that either.
But it is true that current queue balancing and stream mapping logic doesn't take account of different stream's weight. To deal with the problem of heavy stream from one tenant, under current stream infra, you can assign multiple streams for the tenant, whose streamGuids different from each other. The more unrelated/random those streamGuid to each other, the better balancing will be achieved across different queues, if using HashRingBasedStreamQueueMapper
Thank you for the explanation - that makes sense.
I'll look into mapping a set of streams to the tenant to help alleviate the load on the single agent.