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

HttpClient contention due to shared CTS registrations #110323

Open
MihaZupan opened this issue Dec 2, 2024 · 1 comment
Open

HttpClient contention due to shared CTS registrations #110323

MihaZupan opened this issue Dec 2, 2024 · 1 comment
Labels
Milestone

Comments

@MihaZupan
Copy link
Member

crank --config https://raw.githubusercontent.com/aspnet/Benchmarks/main/scenarios/httpclient.benchmarks.yml --scenario httpclient-kestrel-get --profile aspnet-gold-lin --server.framework net9.0 --client.framework net9.0 --variable useHttpMessageInvoker=true --variable concurrencyPerHttpClient=1 --variable numberOfHttpClients=256 --json 256x1.json
crank --config https://raw.githubusercontent.com/aspnet/Benchmarks/main/scenarios/httpclient.benchmarks.yml --scenario httpclient-kestrel-get --profile aspnet-gold-lin --server.framework net9.0 --client.framework net9.0 --variable useHttpMessageInvoker=true --variable concurrencyPerHttpClient=256 --variable numberOfHttpClients=1 --json 1x256.json

crank --config https://raw.githubusercontent.com/aspnet/Benchmarks/main/scenarios/httpclient.benchmarks.yml --scenario httpclient-kestrel-get --profile aspnet-gold-lin --server.framework net9.0 --client.framework net9.0 --variable concurrencyPerHttpClient=1 --variable numberOfHttpClients=256 --json 256x1-client.json
crank --config https://raw.githubusercontent.com/aspnet/Benchmarks/main/scenarios/httpclient.benchmarks.yml --scenario httpclient-kestrel-get --profile aspnet-gold-lin --server.framework net9.0 --client.framework net9.0 --variable concurrencyPerHttpClient=256 --variable numberOfHttpClients=1 --json 1x256-client.json

At high RPS, the contention behind using a single CancellationTokenSource to handle CancelPendingRequests shows up:

client 256 clients 1 client
Invoker 1,389,074 1,363,790
HttpClient 1,326,386 754,139

A quick test of splitting requests across ProcessorCount CTS instances based on CurrentManagedThreadId recovers the whole perf difference.

When we get around to improving this, we could also consider avoiding the linked CTS allocation we incur per request.

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Dec 2, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

@MihaZupan MihaZupan added this to the Future milestone Dec 2, 2024
@MihaZupan MihaZupan removed the untriaged New issue has not been triaged by the area owner label Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant