Skip to content

Config Max Http Request In NuGet

Zhi Li edited this page Jul 18, 2018 · 1 revision

Issue

https://github.com/NuGet/Home/issues/4538

Problem

Today, NuGet has no consistent story about the number of parallel HTTP requests allowed.

In our Visual Studio extension or NuGet.exe/Dotnet CLI on non-mac OS, there is no http request throttling for package dependency resolving. We end up sending hundreds requests at the same time, restore times out due to default connection limit is 2.

Who is the customer?

Any customer who do restore with limited network resource like on docker, mono..etc.

Current Code

We have a NetworkProtocolUtility.SetConnectionLimit API, but this only works on .NET Framework and sets the value to 64 on non-Mono environments (Mono is set to 1). This API is not called in VS (and should not until we know how it would effect other components in the VS process and if it's even the right solution).

HttpSource has an IThrottle parameter which allows controlling the total number of pending HTTP requests. This is used for --disable-parallel by implementing IThrottle with a semaphore of size 1.

Package.config use maxDegreeOfParallelism which is set to Environment.ProcessorCount by default for dependency fetching and package download & extraction

PackageReference throttling in SourceRepositoryDependencyProvider only on mac for dependency resolving and use MaxDegreeOfConcurrency for package download and extraction. The default value for both are 16

Solution

We should provide a way to control the max http request from NuGet.Config.

<config>
    <add key="maxHttpRequest" value="16" />
</config>

This setting can control all http request number sending from nuget for package dependency resolving and package downloading.

Open question

  1. Do we need a default value for this setting on non-mac scenario? We don't have any throttling on that now, since throttling hurts performance.

  2. Do we still keep high level throttling like throttling in NuGetPackageManager/SourceReposiotryDependencyProvider after we have this low level throttling on httpClient?

Contributing

What's Being Worked On?

Check out the proposals in the accepted & proposed folders on the repository, and active PRs for proposals being discussed today.

Common Problems

Clone this wiki locally