diff --git a/doc/03-cli.md b/doc/03-cli.md index 7aba323a7..99d4272b8 100644 --- a/doc/03-cli.md +++ b/doc/03-cli.md @@ -1014,6 +1014,13 @@ similar use case), and need to support proxies, please provide the `CGI_HTTP_PRO environment variable instead. See [httpoxy.org](https://httpoxy.org/) for further details. +### COMPOSER_MAX_PARALLEL_HTTP + +Set to an integer to configure how many files can be downloaded in parallel. This +defaults to 12 and must be between 1 and 50. If your proxy has issues with +concurrency maybe you want to lower this. Increasing it should generally not result +in performance gains. + ### HTTP_PROXY_REQUEST_FULLURI If you use a proxy, but it does not support the request_fulluri flag, then you diff --git a/src/Composer/Util/HttpDownloader.php b/src/Composer/Util/HttpDownloader.php index 519e17c54..757e5f3c6 100644 --- a/src/Composer/Util/HttpDownloader.php +++ b/src/Composer/Util/HttpDownloader.php @@ -37,7 +37,7 @@ class HttpDownloader private $jobs = array(); private $options = array(); private $runningJobs = 0; - private $maxJobs = 10; + private $maxJobs = 12; private $curl; private $rfs; private $idGen = 0; @@ -71,6 +71,10 @@ class HttpDownloader } $this->rfs = new RemoteFilesystem($io, $config, $options, $disableTls); + + if (is_numeric($maxJobs = getenv('COMPOSER_MAX_PARALLEL_HTTP'))) { + $this->maxJobs = max(1, min(50, (int) $maxJobs)); + } } /**