actions / runner-images

GitHub Actions runner images
MIT License
9.17k stars 2.84k forks source link

Set NuGet's `maxHttpRequestsPerSource` setting to a reasonable value for Linux #9787

Open pjquirk opened 2 weeks ago

pjquirk commented 2 weeks ago

Description

We've seen at least one occurrence of connection limits being hit during dotnet restore on a Linux larger runner, though impact could be larger. According to the documentation (see emphasis):

maxHttpRequestsPerSource Controls the maximum number of parallel requests sent from NuGet to every package source for package dependency resolution and downloads. The default value on dotnet.exe is Int32.MaxValue which is derived from HttpClientHandler.MaxConnectionsPerServer property. This setting has no impact on dotnet.exe for Mac OS because the throttling limit is set to 16 to avoid too many open files error. The default value for NuGet client tools that runs on .NET Framework such as Visual Studio and nuget.exe is 64 on Windows and 1 on Mono. The default value for Packages.config style projects is set to Environment.ProcessorCount. Configuring maxHttpRequestsPerSource property to a value less than the default could impact NuGet performance.

For larger projects this can result in intermittent connection timeouts as the VM can no longer connect to the pool's load balancer (which is restricted to 1024 connections from an individual VM). Some examples from other software:

We could just use the same limit as Windows of 64 or Mac of 16, there's no real heuristic for it other than not being "unlimited".

Platforms affected

Runner images affected

Image version and build link

All current Linux images

Is it regression?

No

Expected behavior

Limited connections being made from nuget restore and dotnet restore on Linux, which lessens chance of intermittent connection timeouts.

Actual behavior

Projects with many packages on the same source can have intermittent connection timeouts.

Repro steps

N/A

erik-bershel commented 1 week ago

Hey @pjquirk! We'll take a look ASAP. Thank you for bringing it into our attention.