Skip to content
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

Update performance-tuning.md #7028

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions nservicebus/gateway/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,3 @@ netsh http show urlacl

For more information see the relevant [Netsh commands for HTTP
](https://msdn.microsoft.com/en-us/library/windows/desktop/cc307236).

## ServicePointManager HTTP connections

include: servicepoint-manager-connection-limit
13 changes: 0 additions & 13 deletions transports/servicepoint-manager-connection-limit.include.md

This file was deleted.

55 changes: 18 additions & 37 deletions transports/sqs/performance-tuning.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
title: Performance Tuning
summary: Guidance to tweak the performance of the SQS transport
component: SQS
reviewed: 2023-05-02
reviewed: 2025-03-06
---

> [!NOTE]
> [!IMPORTANT]
> It is difficult to give performance tuning guidelines that will be generally applicable. Results may vary greatly depending on many factors such as bandwidth, latency, client version, and much more. As always with performance tuning: Measure, don't assume.

The Amazon SQS transport uses HTTP/S connections to send and receive messages from the AWS web services. The performance of the operations performed by the transport are subjected to the latency of the connection between the endpoint and SQS.
Expand All @@ -14,59 +14,40 @@ The Amazon SQS transport uses HTTP/S connections to send and receive messages fr

It is possible to increase the maximum concurrency to increase the throughput of a single endpoint. For more information about how to tune the endpoint message processing, consult the [tuning guide](/nservicebus/operations/tuning.md).

In Version 4 and higher, the transport will automatically increase the degree of parallelism by applying the following formula.
The transport will automatically increase the degree of parallelism by applying the following formula.

```
Degree of parallelism = Math.Ceiling(MaxConcurrency / NumberOfMessagesToFetch)
```

The following examples illustrate how the formula is applied when the concurrency is greater or equal to 10.

|`MaxConcurrency` | `DegreeOfReceiveParallelism` | `NumberOfMessagesToFetch` |
|DegreeOfReceiveParallelism | MaxConcurrency | NumberOfMessagesToFetch |
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI the order of these columns has been originally chosen like this because the thought process was that someone coming from NServiceBus might be most likely familiar with max concurrency (either the default value or the value they have explicitly set). We were assuming someone would then come from the angle of "I set the concurrency to LimitProcessingConcurrencyTo(100) and which row is that in the table..."

I would still argue the previous way makes more sense for most users. // cc @mauroservienti

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting! then can we flip the formula? As a reader, I expect the table to match the order of the formula

Copy link
Contributor

@danielmarbach danielmarbach Mar 10, 2025

Choose a reason for hiding this comment

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

What if you use the following order?

|MaxConcurrency | NumberOfMessagesToFetch | DegreeOfReceiveParallelism |

then it reads naturally from left to right following the formula and the two first columns are the input formula and the right most is the result.

| :-: |:-:|:-:|
| 1 | 1 | 1 |
| 2 | 1 | 2 |
| 3 | 1 | 3 |
| 4 | 1 | 4 |
| 5 | 1 | 5 |
| 6 | 1 | 6 |
| 7 | 1 | 7 |
| 8 | 1 | 8 |
| 9 | 1 | 9 |
| 10 | 1 | 10 |
| 19 | 2 | 10 |
| 21 | 3 | 10 |
| 100 | 10 | 10 |
| 1 | 2 | 2 |
| 1 | 3 | 3 |
| 1 | 4 | 4 |
| 1 | 5 | 5 |
| 1 | 6 | 6 |
| 1 | 7 | 7 |
| 1 | 8 | 8 |
| 1 | 9 | 9 |
| 1 | 10 | 10 |
| 2 | 19 | 10 |
| 3 | 21 | 10 |
| 10 | 100 | 10 |

Each parallel message retrieval requires one long polling connection.

> [!NOTE]
> [!WARNING]
> Changing the maximum concurrency will influence the total number of operations against SQS and can result in higher costs.

## Number of connections

A single endpoint requires multiple connections. Connections might be established or reused due to the connection pooling of the HTTP client infrastructure. By default, a single SQS client has a connection limit of 50 connections. When more than 50 connections are used, the endpoint connections will get queued up, and performance might decrease.

It is possible to set the `ConnectionLimit` property on the client programmatically by overriding the [SQS client](/transports/sqs/configuration-options.md#sqs-client) or the [SNS client](/transports/sqs/configuration-options.md#sns-client) as needed, or by setting the `ServicePointManager.DefaultConnectionLimit` (recommended).

include: servicepoint-manager-connection-limit

## Sending small messages

If the endpoint is sending a lot of small messages (http message size < 1460 bytes) it might be beneficial to turn off the [NagleAlgorithm](https://en.wikipedia.org/wiki/Nagle's_algorithm).

To disable Nagle for a specific endpoint URI use:

```
var servicePoint = ServicePointManager.FindServicePoint(new Uri("sqs-endpoint-uri"));
servicePoint.UseNagleAlgorithm = false;
```

to find the endpoint URIs used, consult the [AWS Regions and Endpoints](https://docs.aws.amazon.com/general/latest/gr/rande.html) documentation. It is also possible to disable Nagle globally for the Application Domain by applying:

```
ServicePointManager.UseNagleAlgorithm = false;
```
It is possible to set the `ConnectionLimit` property on the client programmatically by overriding the [SQS client](/transports/sqs/configuration-options.md#sqs-client) or the [SNS client](/transports/sqs/configuration-options.md#sns-client) as needed.

## Known Limitations

Expand Down