orleans icon indicating copy to clipboard operation
orleans copied to clipboard

Using streams with RabbitMQ

Open TulkasLaugh opened this issue 8 years ago • 4 comments

Hi, I'm learning about Streams and am interested in using it together with a message queuing system like RabbitMQ. My use case can have potentially a large number of requests and I want to be able to implement throttling (such as limiting the number of Grains that are doing work at a time) and work priority. My use case is similar to a cloud base Borg Hivemind trying to conquer the universe.

I was thinking to have a master queue like RabbitMQ hold all the tasks that a Borg unit would do and a large number of BorgUnitGrain would subscribe to and perform tasks listed in the RabbitMQ master queue as they receive them.

I want to be able to control concurrency and throttling on a per planet basis for assimilation, so multiple planets could be marked, but I only want a set number of BorgUnitGrains to be working on a planet at a time. I was thinking that I can control concurrency by having an orchestrator control what tasks get pushed onto RabbitMQ to be divided up by the BorgUnitGrains. Do you guys have any recommendations for what I'm trying to do?

TulkasLaugh avatar Sep 12 '18 19:09 TulkasLaugh

Sounds like a cool use case, but I will need more information before I can give suggestions :)

Are you planning to build a stream provider on top of RabbitMQ or do you want to use our existing stream provider with RabbitMQ somehow?

You mentioned throttling, limiting number of grains doing work at a time. Is this streaming specific or is it just in general you want maximum X amount of grain running in the cluster?

I want to be able to control concurrency and throttling on a per planet basis for assimilation

what is a planet in this case, a queue, a silo?

xiazen avatar Sep 17 '18 20:09 xiazen

I want to use the existing Simple Stream Provider but I was under the impression that RabbitMQ might be needed. The planet would be a queue. I want in general maximum X amount of grain running in a cluster. However, I want to divy up those grains appropriately to the correct planet as work for the planet comes in or new planets get marked.

Let me run through a scenario.

The Borg mark Planet A for assimilation, it's determined that 2,000 BorgUnitGrain should be working on it at a time and overall there are 20,000 BorgUnitGrain available in the pool of resources (number of grains that could be simultaneously running at a time amongst all the silos I have). I give 10,000 tasks that need to be done for Planet A, I want a PlanetQueueGrain to only send 2,000 tasks at a time to be worked on by the BorgUnitGrain (which would update PlanetQueueGrain for when a task is completed).

A new Planet B is marked for assimilation, 8,000 BorgUnitGrains should be working on the assimilation tasks at at time and I also mark Planet C for assimilation and I want 12,000 BorgUnitGrains to be working on assimilation tasks at a time. 50,000 tasks are given to Planet B to be worked on and 100,000 are given to Planet C to be worked on.

So I'm hoping to achieve 1 master stream, 20,000 BorgUnitGrains listening in on it and I control concurrency through PlanetQueueGrain only feeding a certain number of tasks at a time to be processed.

TulkasLaugh avatar Sep 18 '18 14:09 TulkasLaugh

By the look of it. I think it look more like a StatelessWorker scenario if no state is needed, or a general grain scenario. Since each BorgUnitGrain is going to work on a different task, which is distributed by the PlanetGrain. And there's no specialization difference between BorgUnitGrains, meaning they are identical in code. So to me, you just need a PlanetGrain constantly give task to available BorgUnitGrain in the pool (the 2000 BorgUnitGrain which is assigned to this task), and hang idle when no BorgUnitGrain available. In other words, it is more like a AsyncPipeLine use case applied to grains.

I don't see many streaming traits in your scenario, but I maybe wrong. To me, streaming is needed when each consumer want to consume the same stream of tasks, but want to apply different processing to the tasks. Or each BorgUnitGrain has different specialization, so different type of BorgUnitGrain consume a different stream of a specific type of task, and do their own unique processing on the tasks. Neither of the two cases looks like your scenario. I'm not saying that's the only two cases which you should use stream with, but just listing the first two popped into my mind as an example. But I cannot wrap my head around why your scenario needs streaming, which is what I want to convey with my examples.

And sorry for the late update. Has been busy.

xiazen avatar Mar 18 '19 22:03 xiazen

close due to issue being months old. Hope I helped :)

xiazen avatar Jul 12 '19 20:07 xiazen