Derive coroutine HTTP pool sizing

This commit is contained in:
Chirag Aggarwal
2026-04-06 13:38:03 +05:30
parent 00c0f8d7fa
commit b048bd3d8e
2 changed files with 4 additions and 6 deletions
-5
View File
@@ -1,10 +1,5 @@
<?php
// Coroutine HTTP serves requests in a single long-lived process.
putenv('_APP_POOL_PROCESS_COUNT=1');
$_ENV['_APP_POOL_PROCESS_COUNT'] = '1';
$_SERVER['_APP_POOL_PROCESS_COUNT'] = '1';
require_once __DIR__ . '/init.php';
require_once __DIR__ . '/init/span.php';
+4 -1
View File
@@ -245,8 +245,11 @@ $register->set('pools', function () {
$maxConnections = (int) System::getEnv('_APP_CONNECTIONS_MAX', 151);
$instanceConnections = $maxConnections / (int) System::getEnv('_APP_POOL_CLIENTS', 14);
$scriptPath = \str_replace('\\', '/', (string) ($_SERVER['SCRIPT_FILENAME'] ?? ''));
$isCoroutineHttp = \str_ends_with($scriptPath, '/app/http.php');
$workerCount = intval(System::getEnv('_APP_CPU_NUM', swoole_cpu_num())) * intval(System::getEnv('_APP_WORKER_PER_CORE', 6));
$processCount = max(1, (int) System::getEnv('_APP_POOL_PROCESS_COUNT', (string) $workerCount));
$processCount = $isCoroutineHttp ? 1 : $workerCount;
$poolSize = max(1, (int)($instanceConnections / $processCount));
foreach ($connections as $key => $connection) {