-
Notifications
You must be signed in to change notification settings - Fork 16
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
Review Poller Concurrency Design #38
Comments
We had an internal doc readout that explains how JustSaying manages concurrency during message handling and why did they move away from a concurrency strategy that is similar to what AWS Message Processing Framework for .NET uses currently. JustSaying has a concept called SubscriptionGroups which is a collection of multiple SQS queues with the same shared configuration. By default, each queue has its own SubscriptionGroup. When a concurrency limit is set on a subscription group, this limit is shared across all SQS queues belonging to the same group. This means that if the concurrency limit is set to 10, then the combined maximum number of concurrently handled messages across all queues would be 10. SubsciptionGroups are based on Channels based data structures. Benefits of SubscriptionGroupsSubscription group offers throttled access to a shared resource that is being used by multiple handlers concurrently. Imagine a scenario in which you have several queues whose handlers all hit the same database. To be resilient under load, it's important to not overload the database by allowing too many requests through. Using subscription groups would put a concurrency limit that is shared across all handlers. Drawbacks of Using Subscription GroupsSubscription groups induce a constant backpressure of messages that is governed by the WithPrefetch extension method. This controls the number of messages that should be read from SQS each time it makes a call. Each SQS queue within the group will prefetch 1 batch of messages during the first iteration. Subsequently, as soon as 1 message is being processed from a batch, the next batch is fetched pre-emptively. The downside to this approach is that during each polling request, the user is receiving more messages than what can be consumed. These messages are buffered until a worker is available and their visibility is constantly being monitored and extended in the background. This can have business impact for customers since requests for extending visibility of messages are chargeable. This drawback was also mentioned in one of the PR comments left by a maintainer of JustSaying. Concurrency management in subscription groups is decoupled from the message polling logic. Concurrency limits will only restrict the number of handlers being invoked across all SQS queues but it does not influence the number of messages that will be fetched from SQS during each service call. Additionally, messages that are polled from multiple SQS queues are buffered asynchronously and are interleaved. Since there are no guarantees on ordering of messages, JustSaying does not support FIFO handling of messages and also has an open GitHub issue about it. Why did JustSaying opt to use a Channels based approach to concurrency management?This GitHub issue outlines the concurrency related issues in JustSaying prior to V7. Below is a summary of it: The had an interface called IMessageProcessingStrategy with the following members
Imagine a scenario where a single instance
They did not have a thread-safe way to maintain a count of ConclusionThere are no user reported issues with the concurrency strategy currently used by AWS Message Processing Framework for .NET. It is stable with extensive test coverage around it. We currently do not plan to support setting a concurrency limit that is shared across multiple SQS queues and therefore have decided to stick to our current concurrency management startegy. |
Originally posted by @slang25 in #35 (comment)
I'd like to merge the PR that comment was left on sooner to fix a bug in the current implementation to unblock other areas of work, so creating this to track and discuss revisiting the poller design. DOTNET-6916 tracks this in the internal issue tracker.
The text was updated successfully, but these errors were encountered: