Skip to content

Add ability to set max calls across all sessions#23282

Closed
JoshLove-msft wants to merge 14 commits intoAzure:mainfrom
JoshLove-msft:sb-dyn-concurrency-2
Closed

Add ability to set max calls across all sessions#23282
JoshLove-msft wants to merge 14 commits intoAzure:mainfrom
JoshLove-msft:sb-dyn-concurrency-2

Conversation

@JoshLove-msft
Copy link
Copy Markdown
Member

No description provided.

@JoshLove-msft JoshLove-msft requested a review from jsquire as a code owner August 12, 2021 01:54
@ghost ghost added the Service Bus label Aug 12, 2021
@JoshLove-msft JoshLove-msft requested a review from mathewc August 12, 2021 01:54
@JoshLove-msft
Copy link
Copy Markdown
Member Author

JoshLove-msft commented Aug 12, 2021

Actually, hold off on reviewing please - need to make a few more updates.

@JoshLove-msft JoshLove-msft reopened this Aug 12, 2021
@JoshLove-msft
Copy link
Copy Markdown
Member Author

/azp run net - servicebus - tests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@JoshLove-msft
Copy link
Copy Markdown
Member Author

/azp run net - servicebus - tests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@JoshLove-msft
Copy link
Copy Markdown
Member Author

/azp run net - servicebus - tests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@JoshLove-msft
Copy link
Copy Markdown
Member Author

/azp run net - servicebus - tests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@JoshLove-msft
Copy link
Copy Markdown
Member Author

/azp run net - servicebus - tests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@JoshLove-msft
Copy link
Copy Markdown
Member Author

/azp run net - servicebus - tests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@JoshLove-msft
Copy link
Copy Markdown
Member Author

/azp run net - servicebus - tests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@JoshLove-msft
Copy link
Copy Markdown
Member Author

/azp run net - servicebus - tests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@JoshLove-msft
Copy link
Copy Markdown
Member Author

/azp run net - servicebus - tests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@JoshLove-msft
Copy link
Copy Markdown
Member Author

/azp run net - servicebus - tests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@JoshLove-msft
Copy link
Copy Markdown
Member Author

JoshLove-msft commented Aug 16, 2021

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

@JoshLove-msft
Copy link
Copy Markdown
Member Author

/azp run net - servicebus - tests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@JoshLove-msft
Copy link
Copy Markdown
Member Author

/azp run net - servicebus - tests

@azure-pipelines
Copy link
Copy Markdown

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

/// accept session requests.
/// </summary>
private SemaphoreSlim MaxConcurrentAcceptSessionsSemaphore { get; }
private readonly SemaphoreSlim _maxConcurrentAcceptSessionsSemaphore = new(0, int.MaxValue);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing we don't want to recreate this when concurrency is changed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, we use the same approach as for the other semaphore - release/WaitAsync to change available threads

Comment on lines +321 to +330
/// <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>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// <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>

Comment on lines +151 to +159
/// 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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// 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.

@mathewc
Copy link
Copy Markdown
Member

mathewc commented Aug 17, 2021

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.

@JoshLove-msft
Copy link
Copy Markdown
Member Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants