Merge pull request #2852 from appwrite/feat-configurable-worker-num
feat: add option to configure worker numbers
This commit is contained in:
commit
139d7cb502
7 changed files with 23 additions and 1 deletions
1
.env
1
.env
|
@ -1,6 +1,7 @@
|
||||||
_APP_ENV=production
|
_APP_ENV=production
|
||||||
_APP_ENV=development
|
_APP_ENV=development
|
||||||
_APP_LOCALE=en
|
_APP_LOCALE=en
|
||||||
|
_APP_WORKER_PER_CORE=6
|
||||||
_APP_CONSOLE_WHITELIST_ROOT=disabled
|
_APP_CONSOLE_WHITELIST_ROOT=disabled
|
||||||
_APP_CONSOLE_WHITELIST_EMAILS=
|
_APP_CONSOLE_WHITELIST_EMAILS=
|
||||||
_APP_CONSOLE_WHITELIST_IPS=
|
_APP_CONSOLE_WHITELIST_IPS=
|
||||||
|
|
|
@ -134,6 +134,7 @@ ENV DEBUG=$DEBUG
|
||||||
ENV _APP_SERVER=swoole \
|
ENV _APP_SERVER=swoole \
|
||||||
_APP_ENV=production \
|
_APP_ENV=production \
|
||||||
_APP_LOCALE=en \
|
_APP_LOCALE=en \
|
||||||
|
_APP_WORKER_PER_CORE= \
|
||||||
_APP_DOMAIN=localhost \
|
_APP_DOMAIN=localhost \
|
||||||
_APP_DOMAIN_TARGET=localhost \
|
_APP_DOMAIN_TARGET=localhost \
|
||||||
_APP_HOME=https://appwrite.io \
|
_APP_HOME=https://appwrite.io \
|
||||||
|
|
|
@ -176,6 +176,15 @@ return [
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'question' => '',
|
'question' => '',
|
||||||
'filter' => ''
|
'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' => ''
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
|
@ -23,9 +23,11 @@ use Utopia\Logger\Log\User;
|
||||||
$http = new Server("0.0.0.0", App::getEnv('PORT', 80));
|
$http = new Server("0.0.0.0", App::getEnv('PORT', 80));
|
||||||
|
|
||||||
$payloadSize = 6 * (1024 * 1024); // 6MB
|
$payloadSize = 6 * (1024 * 1024); // 6MB
|
||||||
|
$workerNumber = swoole_cpu_num() * intval(App::getEnv('_APP_WORKER_PER_CORE', 6));
|
||||||
|
|
||||||
$http
|
$http
|
||||||
->set([
|
->set([
|
||||||
|
'worker_num' => $workerNumber,
|
||||||
'open_http2_protocol' => true,
|
'open_http2_protocol' => true,
|
||||||
// 'document_root' => __DIR__.'/../public',
|
// 'document_root' => __DIR__.'/../public',
|
||||||
// 'enable_static_handler' => true,
|
// 'enable_static_handler' => true,
|
||||||
|
|
|
@ -46,9 +46,12 @@ $stats->create();
|
||||||
|
|
||||||
$containerId = uniqid();
|
$containerId = uniqid();
|
||||||
$statsDocument = null;
|
$statsDocument = null;
|
||||||
|
$workerNumber = swoole_cpu_num() * intval(App::getEnv('_APP_WORKER_PER_CORE', 6));
|
||||||
|
|
||||||
$adapter = new Adapter\Swoole(port: App::getEnv('PORT', 80));
|
$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);
|
$server = new Server($adapter);
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ services:
|
||||||
- influxdb
|
- influxdb
|
||||||
environment:
|
environment:
|
||||||
- _APP_ENV
|
- _APP_ENV
|
||||||
|
- _APP_WORKER_PER_CORE
|
||||||
- _APP_LOCALE
|
- _APP_LOCALE
|
||||||
- _APP_CONSOLE_WHITELIST_ROOT
|
- _APP_CONSOLE_WHITELIST_ROOT
|
||||||
- _APP_CONSOLE_WHITELIST_EMAILS
|
- _APP_CONSOLE_WHITELIST_EMAILS
|
||||||
|
@ -142,6 +143,7 @@ services:
|
||||||
- redis
|
- redis
|
||||||
environment:
|
environment:
|
||||||
- _APP_ENV
|
- _APP_ENV
|
||||||
|
- _APP_WORKER_PER_CORE
|
||||||
- _APP_OPTIONS_ABUSE
|
- _APP_OPTIONS_ABUSE
|
||||||
- _APP_OPENSSL_KEY_V1
|
- _APP_OPENSSL_KEY_V1
|
||||||
- _APP_REDIS_HOST
|
- _APP_REDIS_HOST
|
||||||
|
@ -152,6 +154,8 @@ services:
|
||||||
- _APP_DB_USER
|
- _APP_DB_USER
|
||||||
- _APP_DB_PASS
|
- _APP_DB_PASS
|
||||||
- _APP_USAGE_STATS
|
- _APP_USAGE_STATS
|
||||||
|
- _APP_LOGGING_PROVIDER
|
||||||
|
- _APP_LOGGING_CONFIG
|
||||||
|
|
||||||
appwrite-worker-database:
|
appwrite-worker-database:
|
||||||
image: <?php echo $organization; ?>/<?php echo $image; ?>:<?php echo $version."\n"; ?>
|
image: <?php echo $organization; ?>/<?php echo $image; ?>:<?php echo $version."\n"; ?>
|
||||||
|
|
|
@ -89,6 +89,7 @@ services:
|
||||||
environment:
|
environment:
|
||||||
- _APP_ENV
|
- _APP_ENV
|
||||||
- _APP_LOCALE
|
- _APP_LOCALE
|
||||||
|
- _APP_WORKER_PER_CORE
|
||||||
- _APP_CONSOLE_WHITELIST_ROOT
|
- _APP_CONSOLE_WHITELIST_ROOT
|
||||||
- _APP_CONSOLE_WHITELIST_EMAILS
|
- _APP_CONSOLE_WHITELIST_EMAILS
|
||||||
- _APP_CONSOLE_WHITELIST_IPS
|
- _APP_CONSOLE_WHITELIST_IPS
|
||||||
|
@ -172,6 +173,7 @@ services:
|
||||||
- redis
|
- redis
|
||||||
environment:
|
environment:
|
||||||
- _APP_ENV
|
- _APP_ENV
|
||||||
|
- _APP_WORKER_PER_CORE
|
||||||
- _APP_OPTIONS_ABUSE
|
- _APP_OPTIONS_ABUSE
|
||||||
- _APP_OPENSSL_KEY_V1
|
- _APP_OPENSSL_KEY_V1
|
||||||
- _APP_REDIS_HOST
|
- _APP_REDIS_HOST
|
||||||
|
|
Loading…
Reference in a new issue