From b048bd3d8ecbf09b88a69130b4c226e355d2b498 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Mon, 6 Apr 2026 13:38:03 +0530 Subject: [PATCH] Derive coroutine HTTP pool sizing --- app/http.php | 5 ----- app/init/registers.php | 5 ++++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/http.php b/app/http.php index 34a8981932..7f6faecaa7 100644 --- a/app/http.php +++ b/app/http.php @@ -1,10 +1,5 @@ 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) {