我們用 gateway-worker 做的后臺(tái)服務(wù)
用 WebSocket 協(xié)議傳輸數(shù)據(jù)
用戶量大了之后感覺(jué)卡頓
懷疑是 代碼層調(diào)用 api 之類的接口 堵塞了線程。
我們可以調(diào)大 BusinessWorker 數(shù)量 解決這個(gè)問(wèn)題嗎?
BusinessWorker 數(shù)量可以無(wú)限調(diào)大嗎 ?
目前 BusinessWorker 的值 應(yīng)該調(diào)多少 才能發(fā)揮最大硬件性能一直是一個(gè)疑惑!
老大說(shuō) 可以 開(kāi) 32 個(gè)。
調(diào)用 api 建議用 http://m.wtbis.cn/plugin/157
openai 用 http://m.wtbis.cn/plugin/157 來(lái)調(diào)用,是非阻塞的。
businessWorker可以開(kāi)成cpu的3-8倍。不能無(wú)限大。
POST /api.php HTTP/1.1
Host: tts-dev.testhost.com:8054
User-Agent: workerman/http-client
Connection: keep-alive
0: Content-Type: application/json
1: Authorization:
Content-Type: application/x-www-form-urlencoded
Content-Length: 158
text=Hello%21+I%E2%80%99m+your+English+teacher%2CDo+you+have+an+English+name%3FWhat%E2%80%99s+your+English+name%3F&voice_name=girl_bianca.mp3&text_language=en
PHP Deprecated: long2ip(): Passing null to parameter #1 ($ip) of type int is deprecated in /Users/wheng/phpDevelopment/UtalkLearn/vendor/workerman/gateway-worker/src/Lib/Gateway.php on line 1128
Deprecated: long2ip(): Passing null to parameter #1 ($ip) of type int is deprecated in /Users/wheng/phpDevelopment/UtalkLearn/vendor/workerman/gateway-worker/src/Lib/Gateway.php on line 1128
不知道為啥,我 在 gateway-worker 里的業(yè)務(wù)代碼 調(diào)用 Workerman\Http\Client 發(fā)送一個(gè) 異步請(qǐng)求,會(huì)牽扯到
這個(gè)錯(cuò)誤
"require": {
"workerman/gateway-worker": "^3.1",
"symfony/yaml": "^6.3",
"workerman/redis-queue": "^1.1",
"james-heinrich/getid3": "^1.9",
"php-amqplib/php-amqplib": "^3.6",
"predis/predis": "^2.2",
"react/promise": "^3.0",
"overtrue/pinyin": "^5.3",
"workerman/http-client": "^2.2"
}
這是項(xiàng)目依賴
http 接口異步返回?cái)?shù)據(jù), 調(diào)用Gateway::sendToCurrentClient($message); 給當(dāng)前用戶反饋消息, 就出發(fā)這個(gè)錯(cuò)誤了。
我把 Gateway::sendToCurrentClient($message); 改成 Gateway::sendToClient(getClientId(), $message);
能湊合用了,但是這里肯定有BUG。