1
0
Fork 0
mirror of synced 2024-07-03 05:31:38 +12:00

Merge pull request #2852 from appwrite/feat-configurable-worker-num

feat: add option to configure worker numbers
This commit is contained in:
Torsten Dittmann 2022-02-28 16:10:11 +01:00 committed by GitHub
commit 139d7cb502
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 1 deletions

1
.env
View file

@ -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=

View file

@ -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 \

View file

@ -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' => ''
] ]
], ],
], ],

View file

@ -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,

View file

@ -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);

View file

@ -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"; ?>

View file

@ -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