Config Max Http Request In NuGet
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
-
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.
-
Do we still keep high level throttling like throttling in NuGetPackageManager/SourceReposiotryDependencyProvider after we have this low level throttling on httpClient?
Pages 155
Home
Contributing
Specs
Incubation
Reviewing
- Centrally-managing-NuGet-package-versions
- Package Applicability
- Package Vulnerability
- dotnet list package --vulnerable
- Machine-readable output for dotnet list package
- Support Package Renames
- Advanced Search on NuGet.org
Reviewed
Implemented
- Enhanced package upload workflow
- Register package signing certificates
- Organizations on NuGet.org
- 2 Factor Auth for NuGet.org sign in
- Add nuget sources command to the dotnet CLI
- Author Package Signing
- Backporting PC to msbuild restore
- Deprecate packages
- Dotnet list package
- Enable repeatable package restore using lock file
- NuGet Client Package Debugging
- NuGet Package Debugging & Symbols Improvements
- NuGet Package Identity Verification
- NuGet Package Signing Client Policy
- NuGet Sign Command
- NuGet Verify Command
- Storing trusted repository
- Package Signatures Technical Details
- Package signing
- Packages.config SHA Validation
- Packaging Icon, License and Documentation within the nupkg
- Repository Signatures and Countersignatures Technical Specification
- Repository Signatures
- Show outdated packages
- Symbols Package Upload and Delete Workflow