diff --git a/.env b/.env index 2b9835948..f6a0f4e7e 100644 --- a/.env +++ b/.env @@ -1,6 +1,7 @@ _APP_ENV=production _APP_ENV=development _APP_LOCALE=en +_APP_WORKER_PER_CORE=6 _APP_CONSOLE_WHITELIST_ROOT=disabled _APP_CONSOLE_WHITELIST_EMAILS= _APP_CONSOLE_WHITELIST_IPS= diff --git a/Dockerfile b/Dockerfile index 511621ed3..aabe00373 100755 --- a/Dockerfile +++ b/Dockerfile @@ -134,6 +134,7 @@ ENV DEBUG=$DEBUG ENV _APP_SERVER=swoole \ _APP_ENV=production \ _APP_LOCALE=en \ + _APP_WORKER_PER_CORE= \ _APP_DOMAIN=localhost \ _APP_DOMAIN_TARGET=localhost \ _APP_HOME=https://appwrite.io \ diff --git a/app/config/variables.php b/app/config/variables.php index 5e0f8fb5e..60f35e5e9 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -176,6 +176,15 @@ return [ 'required' => false, 'question' => '', 'filter' => '' + ], + [ + 'name' => '_APP_WORKER_PER_CORE', + 'description' => 'Internal Worker per core for the API, Realtime and Executor containers. Can be configured to optimize performance.', + 'introduction' => '0.13.0', + 'default' => 6, + 'required' => false, + 'question' => '', + 'filter' => '' ] ], ], diff --git a/app/http.php b/app/http.php index adc3b3c93..b94c0ab99 100644 --- a/app/http.php +++ b/app/http.php @@ -23,9 +23,11 @@ use Utopia\Logger\Log\User; $http = new Server("0.0.0.0", App::getEnv('PORT', 80)); $payloadSize = 6 * (1024 * 1024); // 6MB +$workerNumber = swoole_cpu_num() * intval(App::getEnv('_APP_WORKER_PER_CORE', 6)); $http ->set([ + 'worker_num' => $workerNumber, 'open_http2_protocol' => true, // 'document_root' => __DIR__.'/../public', // 'enable_static_handler' => true, diff --git a/app/realtime.php b/app/realtime.php index d72af7f60..d3170813a 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -46,9 +46,12 @@ $stats->create(); $containerId = uniqid(); $statsDocument = null; +$workerNumber = swoole_cpu_num() * intval(App::getEnv('_APP_WORKER_PER_CORE', 6)); $adapter = new Adapter\Swoole(port: App::getEnv('PORT', 80)); -$adapter->setPackageMaxLength(64000); // Default maximum Package Size (64kb) +$adapter + ->setPackageMaxLength(64000) // Default maximum Package Size (64kb) + ->setWorkerNumber($workerNumber); $server = new Server($adapter); diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index c29c32445..063ccaa99 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -66,6 +66,7 @@ services: - influxdb environment: - _APP_ENV + - _APP_WORKER_PER_CORE - _APP_LOCALE - _APP_CONSOLE_WHITELIST_ROOT - _APP_CONSOLE_WHITELIST_EMAILS @@ -142,6 +143,7 @@ services: - redis environment: - _APP_ENV + - _APP_WORKER_PER_CORE - _APP_OPTIONS_ABUSE - _APP_OPENSSL_KEY_V1 - _APP_REDIS_HOST @@ -152,6 +154,8 @@ services: - _APP_DB_USER - _APP_DB_PASS - _APP_USAGE_STATS + - _APP_LOGGING_PROVIDER + - _APP_LOGGING_CONFIG appwrite-worker-database: image: /: diff --git a/docker-compose.yml b/docker-compose.yml index 61bf06775..a4819ab05 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -89,6 +89,7 @@ services: environment: - _APP_ENV - _APP_LOCALE + - _APP_WORKER_PER_CORE - _APP_CONSOLE_WHITELIST_ROOT - _APP_CONSOLE_WHITELIST_EMAILS - _APP_CONSOLE_WHITELIST_IPS @@ -172,6 +173,7 @@ services: - redis environment: - _APP_ENV + - _APP_WORKER_PER_CORE - _APP_OPTIONS_ABUSE - _APP_OPENSSL_KEY_V1 - _APP_REDIS_HOST