WIP fix too many connections
This commit is contained in:
parent
44ca7d9459
commit
a6ffab09df
2 changed files with 9 additions and 6 deletions
|
@ -35,6 +35,9 @@ Runtime::enableCoroutine(SWOOLE_HOOK_ALL);
|
|||
|
||||
$realtime = new Realtime();
|
||||
|
||||
$dbPool = $register->get('dbPool');
|
||||
$redisPool = $register->get('redisPool');
|
||||
|
||||
/**
|
||||
* Table for statistics across all workers.
|
||||
*/
|
||||
|
@ -354,15 +357,15 @@ $server->onWorkerStart(function (int $workerId) use ($server, $register, $stats,
|
|||
Console::error('Failed to restart pub/sub...');
|
||||
});
|
||||
|
||||
$server->onOpen(function (int $connection, SwooleRequest $request) use ($server, $register, $stats, &$realtime, $logError) {
|
||||
$server->onOpen(function (int $connection, SwooleRequest $request) use ($server, $dbPool, $redisPool, $stats, &$realtime, $logError) {
|
||||
$app = new App('UTC');
|
||||
$request = new Request($request);
|
||||
$response = new Response(new SwooleResponse());
|
||||
|
||||
/** @var PDO $db */
|
||||
$db = $register->get('dbPool')->get();
|
||||
$db = $dbPool->get();
|
||||
/** @var Redis $redis */
|
||||
$redis = $register->get('redisPool')->get();
|
||||
$redis = $redisPool->get();
|
||||
|
||||
Console::info("Connection open (user: {$connection})");
|
||||
|
||||
|
@ -477,8 +480,8 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server,
|
|||
/**
|
||||
* Put used PDO and Redis Connections back into their pools.
|
||||
*/
|
||||
$register->get('dbPool')->put($db);
|
||||
$register->get('redisPool')->put($redis);
|
||||
$dbPool->put($db);
|
||||
$redisPool->put($redis);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -707,7 +707,7 @@ services:
|
|||
- MYSQL_DATABASE=${_APP_DB_SCHEMA}
|
||||
- MYSQL_USER=${_APP_DB_USER}
|
||||
- MYSQL_PASSWORD=${_APP_DB_PASS}
|
||||
command: 'mysqld --innodb-flush-method=fsync' # add ' --query_cache_size=0' for DB tests
|
||||
command: 'mysqld --innodb-flush-method=fsync --max_connections=49152' # 128 (CPUs) * 6 (Workers) * 64 (Pool size)
|
||||
# command: mv /var/lib/mysql/ib_logfile0 /var/lib/mysql/ib_logfile0.bu && mv /var/lib/mysql/ib_logfile1 /var/lib/mysql/ib_logfile1.bu
|
||||
|
||||
# smtp:
|
||||
|
|
Loading…
Reference in a new issue