Add ability to set max calls across all sessions#23282
Add ability to set max calls across all sessions#23282JoshLove-msft wants to merge 14 commits intoAzure:mainfrom
Conversation
|
Actually, hold off on reviewing please - need to make a few more updates. |
|
/azp run net - servicebus - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run net - servicebus - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
sdk/servicebus/Azure.Messaging.ServiceBus/api/Azure.Messaging.ServiceBus.netstandard2.0.cs
Show resolved
Hide resolved
|
/azp run net - servicebus - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run net - servicebus - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run net - servicebus - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
sdk/servicebus/Azure.Messaging.ServiceBus/src/Processor/ServiceBusProcessor.cs
Outdated
Show resolved
Hide resolved
sdk/servicebus/Azure.Messaging.ServiceBus/src/Processor/ServiceBusProcessor.cs
Show resolved
Hide resolved
|
/azp run net - servicebus - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run net - servicebus - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run net - servicebus - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run net - servicebus - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run net - servicebus - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
It looks like a lot of the flakiness around the session concurrency tests is related to how we were implementing the "fake" cancellation support when accepting sessions. Now that the AMQP lib has been updated to have real cancellation token support, I've updated the OpenLink flows to use it. I've created an issue to track the rest of the updates that are needed - #23333 |
|
/azp run net - servicebus - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run net - servicebus - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| Source = new Source { Address = endpoint.AbsolutePath, FilterSet = filters }, | ||
| Target = new Target { Address = Guid.NewGuid().ToString() } | ||
| Target = new Target { Address = Guid.NewGuid().ToString() }, | ||
| OperationTimeout = _operationTimeout |
| /// accept session requests. | ||
| /// </summary> | ||
| private SemaphoreSlim MaxConcurrentAcceptSessionsSemaphore { get; } | ||
| private readonly SemaphoreSlim _maxConcurrentAcceptSessionsSemaphore = new(0, int.MaxValue); |
There was a problem hiding this comment.
I'm guessing we don't want to recreate this when concurrency is changed?
There was a problem hiding this comment.
Correct, we use the same approach as for the other semaphore - release/WaitAsync to change available threads
| /// <param name="maxConcurrentCallsAcrossAllSessions">If specified, limits the total max concurrent calls to this value. This does not override the | ||
| /// limits specified in <paramref name="maxConcurrentSessions"/> and <paramref name="maxConcurrentCallsPerSession"/>, but acts as further limit | ||
| /// to the total calls. As an example, suppose you want to allow 100 concurrent invocations of the message handler, | ||
| /// and you want to process up to 20 sessions concurrently. You can try setting maxConcurrentSessions to 20, and maxConcurrentCallsPerSession to 5. | ||
| /// However, in practice, your queue might typically have only 10 sessions with messages at a given time. So in order to achieve | ||
| /// your desired throughput, you can instead set maxConcurrentCallsPerSession to 10. This would mean that if your queue ever did have | ||
| /// 20 sessions at a time, you would be doing 200 invocations. In order to prevent this, you can set maxConcurrentCallsAcrossAllSessions to 100. | ||
| /// This allows the processor to attempt to scale up to the maxConcurrentCallsPerSession when the number of available sessions is lower, | ||
| /// while still being able to accept new sessions without breaking your throughput requirement as the number of available sessions | ||
| /// increases.</param> |
There was a problem hiding this comment.
| /// <param name="maxConcurrentCallsAcrossAllSessions">If specified, limits the total max concurrent calls to this value. This does not override the | |
| /// limits specified in <paramref name="maxConcurrentSessions"/> and <paramref name="maxConcurrentCallsPerSession"/>, but acts as further limit | |
| /// to the total calls. As an example, suppose you want to allow 100 concurrent invocations of the message handler, | |
| /// and you want to process up to 20 sessions concurrently. You can try setting maxConcurrentSessions to 20, and maxConcurrentCallsPerSession to 5. | |
| /// However, in practice, your queue might typically have only 10 sessions with messages at a given time. So in order to achieve | |
| /// your desired throughput, you can instead set maxConcurrentCallsPerSession to 10. This would mean that if your queue ever did have | |
| /// 20 sessions at a time, you would be doing 200 invocations. In order to prevent this, you can set maxConcurrentCallsAcrossAllSessions to 100. | |
| /// This allows the processor to attempt to scale up to the maxConcurrentCallsPerSession when the number of available sessions is lower, | |
| /// while still being able to accept new sessions without breaking your throughput requirement as the number of available sessions | |
| /// increases.</param> | |
| /// <param name="maxConcurrentCallsAcrossAllSessions">If specified, limits the total max concurrent calls to the requested value. This does not override the | |
| /// limits specified in <paramref name="maxConcurrentSessions"/> and <paramref name="maxConcurrentCallsPerSession"/>, but acts as further limit | |
| /// to the total calls. As an example, suppose you want to allow 100 concurrent invocations of the message handler, | |
| /// and you want to process up to 20 sessions concurrently. You can try setting <c>maxConcurrentSessions</c> to 20, and <c>maxConcurrentCallsPerSession</c> to 5. | |
| /// However, in practice, your queue might typically have only 10 sessions with messages at a given time. So in order to achieve | |
| /// your desired throughput, you can instead set <c>maxConcurrentCallsPerSession</c> to 10. This would mean that if your queue ever did have | |
| /// 20 sessions at a time, you would be doing 200 invocations. In order to prevent this, you can set <c>maxConcurrentCallsAcrossAllSessions</c> to 100. | |
| /// This allows the processor to attempt to scale up to the <c>maxConcurrentCallsPerSession</c> when the number of available sessions is lower, | |
| /// while still being able to accept new sessions without breaking your throughput requirement as the number of available sessions | |
| /// increases.</param> |
| /// This does not override the limits specified in <see cref="MaxConcurrentSessions"/> and <see cref="MaxConcurrentCallsPerSession"/>, but acts as further limit | ||
| /// to the total calls. As an example, suppose you want to allow 100 concurrent invocations of the message handler, | ||
| /// and you want to process up to 20 sessions concurrently. You can try setting MaxConcurrentSessions to 20, and MaxConcurrentCallsPerSession to 5. | ||
| /// However, in practice, your queue might typically have only 10 sessions with messages at a given time. So in order to achieve | ||
| /// your desired throughput, you can instead set MaxConcurrentCallsPerSession to 10. This would mean that if your queue ever did have | ||
| /// 20 sessions at a time, you would be doing 200 invocations. In order to prevent this, you can set MaxConcurrentCallsAcrossAllSessions to 100. | ||
| /// This allows the processor to attempt to scale up to the MaxConcurrentCallsPerSession when the number of available sessions is lower, | ||
| /// while still being able to accept new sessions without breaking your throughput requirement as the number of available sessions | ||
| /// increases. |
There was a problem hiding this comment.
| /// This does not override the limits specified in <see cref="MaxConcurrentSessions"/> and <see cref="MaxConcurrentCallsPerSession"/>, but acts as further limit | |
| /// to the total calls. As an example, suppose you want to allow 100 concurrent invocations of the message handler, | |
| /// and you want to process up to 20 sessions concurrently. You can try setting MaxConcurrentSessions to 20, and MaxConcurrentCallsPerSession to 5. | |
| /// However, in practice, your queue might typically have only 10 sessions with messages at a given time. So in order to achieve | |
| /// your desired throughput, you can instead set MaxConcurrentCallsPerSession to 10. This would mean that if your queue ever did have | |
| /// 20 sessions at a time, you would be doing 200 invocations. In order to prevent this, you can set MaxConcurrentCallsAcrossAllSessions to 100. | |
| /// This allows the processor to attempt to scale up to the MaxConcurrentCallsPerSession when the number of available sessions is lower, | |
| /// while still being able to accept new sessions without breaking your throughput requirement as the number of available sessions | |
| /// increases. | |
| /// This does not override the limits specified in <see cref="MaxConcurrentSessions"/> and <see cref="MaxConcurrentCallsPerSession"/>, but acts as further limit | |
| /// to the total calls. As an example, suppose you want to allow 100 concurrent invocations of the message handler, | |
| /// and you want to process up to 20 sessions concurrently. You can try setting <c>MaxConcurrentSessions</c> to 20, and <c>MaxConcurrentCallsPerSession</c> to 5. | |
| /// However, in practice, your queue might typically have only 10 sessions with messages at a given time. So in order to achieve | |
| /// your desired throughput, you can instead set <c>MaxConcurrentCallsPerSession</c> to 10. This would mean that if your queue ever did have | |
| /// 20 sessions at a time, you would be doing 200 invocations. In order to prevent this, you can set <c>MaxConcurrentCallsAcrossAllSessions</c> to 100. | |
| /// This allows the processor to attempt to scale up to the <c>MaxConcurrentCallsPerSession</c> when the number of available sessions is lower, | |
| /// while still being able to accept new sessions without breaking your throughput requirement as the number of available sessions | |
| /// increases. |
|
Thanks for doing this work @JoshLove-msft. While it's on hold for now, I do think this need may resurface in the future, so it's good we validated the path forward on it. |
Much appreciated! |
No description provided.