Skip to content

Commit

Permalink
perf: webman的worker 数量默认为CPU的数量
Browse files Browse the repository at this point in the history
  • Loading branch information
gua committed Nov 14, 2023
1 parent ee47d11 commit ead4e3f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 7 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

#默认启用redis,防止报错,在安装redis后自行将file改为redis提升性能
BROADCAST_DRIVER=log
CACHE_DRIVER=redis
QUEUE_CONNECTION=redis
SESSION_DRIVER=redis
CACHE_DRIVER=file
QUEUE_CONNECTION=file
SESSION_DRIVER=file
SESSION_LIFETIME=120

MAIL_DRIVER=smtp
Expand All @@ -44,3 +45,6 @@ MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME=null
MAILGUN_DOMAIN=
MAILGUN_SECRET=

# 用于阻止重复安装
INSTALLED=false
3 changes: 1 addition & 2 deletions webman.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

use Adapterman\Adapterman;
use Workerman\Worker;

Adapterman::init();

$http_worker = new Worker('http://127.0.0.1:7010');
$http_worker->count = 8;
$http_worker->count = swoole_cpu_num() ?? 2;
$http_worker->name = 'AdapterMan';

$http_worker->onWorkerStart = static function () {
Expand Down

0 comments on commit ead4e3f

Please sign in to comment.