question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow configuring HttpClient creation

See original GitHub issue

As part of our performance guidelines, we suggested to customers to tweak ServicePointManager.DefaultConnectionLimit to improve Storage operations. This relevant both for getting data as well as receiving data. With .NET Core the ServicePointManager.DefaultConnectionLimit is not taken into account with the HttpClient anymore. There is a new property called MaxConnectionsPerServer on the HttpClientHandler that needs to be set when the HttpClient is created. The default value of that property is int.Max. With massive concurrent storage operations, the async code running on .NET Core will create thousands of connections which makes the storage operation code slow on .NET Core.

AWS SDK has a possibility to override certain settings of the HttpClient or HttpClientHandler when a client is created. For example MaxConnectionsPerServer can be set on the client configuration object with .NET Core. This allows tweaking the default behaviour of the HTTP client handler.

new AmazonSQSClient(
            credentials,
            new AmazonSQSConfig
            {
                RegionEndpoint = region,
                MaxConnectionsPerServer = someValue,
            })

It would be really beneficial if the HttpClient creation can be somehow controlled or at least configuration like MaxConnectionsPerServer can be set on the created HttpClient to be able to tweak performance if necessary.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
brettsamcommented, Dec 3, 2018

For those using Functions v2, can you give our latest release (anything >= 2.0.12210.0) a try with your scenarios? At the time of this writing, this version is rolling out worldwide, so it may not quite be in all regions just yet.

We added a workaround that fixes a number of our test scenarios involving Storage connection limits. We’ll be absorbing the new change made in Storage 9.4.1, but it will require a little bit of refactoring before that can happen. If you have functions-specific scenarios that still don’t work, please file a separate issue over at https://github.com/Azure/azure-webjobs-sdk/issues, which the Functions team will look into.

2reactions
ryanerdmanncommented, Apr 11, 2018

As customers start taking advantage of IHttpClientFactory from Microsoft.Extensions.Http, there will be a desire to delegate control over creating HttpClient instances to the application. For server applications, this is especially important so they can implement bulkheading, coordinate refreshing DNS changes, etc.

Can we enable the application to plug in some HttpClient factory when creating a CloudBlobClient?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Make HTTP requests using IHttpClientFactory in ASP.NET ...
A new instance of HttpClient is created. The configuration action is called. To create a named client, pass its name into CreateClient :....
Read more >
Use IHttpClientFactory to implement resilient HTTP requests
Provides a central location for naming and configuring logical HttpClient objects. · Codify the concept of outgoing middleware via delegating ...
Read more >
Creating and Using HTTP Client SDKs in .NET 6 - InfoQ
We want to provide a flexible mechanism for configuring HttpClient used as part of the SDK. In this case, we need to supply...
Read more >
Advanced Apache HttpClient Configuration
We are configuring our HttpClient to send all requests via proxy by creating a DefaultProxyRoutePlanner that takes the HttpHost instance ...
Read more >
How to configure web proxy for HttpClient created directly ...
var httpClientFactory = services.GetService<IHttpClientFactory>(); var client = httpClientFactory.CreateClient(NamedHttpClients.ProxiedClient);.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found