国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

當請求數(shù)量比較大的時候會報。redis 鏈接異常

codeninjia

正常使用沒問題。我本地壓測也沒出現(xiàn)這個錯誤。redis的騰訊云的redis 集群。

服務器上會出現(xiàn)這個錯誤。很少但是會出現(xiàn)。
參考網(wǎng)上示例。把read_write_timeout 改成了0 還是不行。想問下大大,可能是什么原因。跟workerman多進程切換有關系嗎
Predis\Connection\AbstractConnection::onConnectionError code:0 msg:Error while reading line from the server.

5277 4 0
4個回答

six

怎么感覺是騰訊云redis 集群的問題

  • codeninjia 2018-07-16

    現(xiàn)在不確定。我試試本地連接騰訊云試試

damao

redis服務端有個timeout配置,是用來關閉不活躍reids連接的,設置成0試下

  • codeninjia 2018-07-16

    恩我在github看到了一個答案是說

    If you are using Predis in a daemon-like script you should set read_write_timeout to -1 if you want to completely disable the timeout (this value works with older and newer versions of Predis). Also, remember that you must disable the default timeout of Redis by setting timeout = 0 in redis.conf or Redis will drop the connection of idle clients after 300 seconds of inactivity.

    說如果守護進程的話使用predis的話要改成-1.

  • damao 2018-07-16

    Also, remember that you must disable the default timeout of Redis by setting timeout = 0 in redis.conf
    我說的是這個,redis服務端的配置

  • codeninjia 2018-07-16

    @16:這個啊我看看。這個值是用來關閉不活躍的鏈接的。如果設置為0 的話意思是不在關閉不活躍的鏈接對吧?那這樣對性能會有影響嗎。我是否可以在我每次我處理完一個請求之后我程序手動關閉當前使用的redis 鏈接?

  • damao 2018-07-16

    可以手動關閉啊

  • codeninjia 2018-07-16

    @16:怎么關閉我在文檔里沒看到。能給下提示嗎

  • codeninjia 2018-07-16

    @16:直接disconnect 就行是吧

  • damao 2018-07-16

    額,我沒用過Predis

  • codeninjia 2018-07-16

    @16:感覺不行啊。redis已經(jīng)設置了timeout=0.還是有報錯。手動關閉的話感覺也有點問題

walkor 打賞

在onWorkerStart里初始化redis,千萬不要在onWorkerStart執(zhí)行前就初始化,onWorkerStart執(zhí)行前初始化redis的redis連接屬于主進程,fork的子進程會自動繼承主進程的這個redis連接,這樣會導致多個子進程都可以對同一個redis連接進行讀寫,導致數(shù)據(jù)錯亂。

  • codeninjia 2018-07-19

    我是在
    $http_worker->onWorkerStart = function($http_worker) {
    // init app
    App::init();
    };
    onWorkerStart 里初始化的單例的redis。平時不會有問題。就是請求量多的時候會報上面那個錯。

phpcreeper

其實和這個問題類似: http://wenda.workerman.net/?/question/2697

  • 暫無評論
年代過于久遠,無法發(fā)表回答
??