-
-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Aws::SQS::QueuePoller? #92
Comments
Hey @sschepens could you have a look at #30 I will try to document / sum up this in the wiki. |
Thanks for the link, one question i have is, is loadblancing between queues actually necessary? If so, it could be enabled somewhere else, keep one (or more?) open poller for every queue and maybe loadbalance on dispatch time or spawn more workers of those who have more priority. |
I realize that it's not a big cost to do a lot o SQS requests, you're not taking account networking costs which shouldn't be much anyway, but it consumes much more network bandwidth to make requests all the time and may impact application performance. |
Not sure if I got your point. But basically the motivation on that was to have only one process Imagine you have 10 processors, and you do a long poll in 5 queues, and you receive 10 messages from each. How can you process those messages? |
Yes, I realized that, that's why I went for the approach of having a separate fetcher for each queue and a configurable pool of processors per queue. |
If you have 10 queues, 25 processors each, and messages only in one queue. You will have 225 processors waiting, and only 25 working hard? Or if you have 10 queues, 25 processors each, and all queues full of messages, will your container handle 250 processors up & running? That's the why Shoryuken load balances the processors across queues. And the approach you wanted you can do using multiple Shoryuken processes, having only one queue per process. But I believe that would be a waste of resources in most cases. |
BTW I'm not saying that your approach is wrong or less efficient. I'm just saying that both have pros & cons. |
Processors with no work should be suspended until messages arrive, this leaves space for other threads to run, so it shouldn't be much of a problem. The only thing I don't like, but it seems like there's no way around it is that a Celluloid Actor runs on it's own thread, instead of being scheduled in a pool of threads. concurrent-ruby has Actors too and are scheduled in a pool of threads, but doing IO in an Actor will block threads, this is a bummer. Something like erlang would be great, where an actor doing IO will get suspended as if it were a thread of it's own, and leave the OS thread free to run another Actor. No approach is better than the other, it's just a matter of trade offs. |
@sschepens thanks for the update.
I couldn't agree more ^ Probably this #236 will give more room to have different strategies. |
Instead of manually sleeping :delay seconds for every queue which doesn't have messages why not use Aws::SQS::QueuePoller which is part of aws-sdk? http://docs.aws.amazon.com/sdkforruby/api/Aws/SQS/QueuePoller.html
I think it's a great alternative and could save us from maintaining some code, like queue pausing.
I'm trying to port current code to using it, but i don't understand yet if there could be problems if for example Fetcher's fetch method blocked polling and dispatching messages until Aws::SQS::QueuePoller ended for some reason or an exception was raised.
Maybe the creators/maintainers could check this up.
Cheers!
Sebastian
The text was updated successfully, but these errors were encountered: