亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

PHP 異步多線程 Curl 應用程序

PHP 異步多線程 Curl 應用程序

PHP
茅侃侃 2023-11-03 17:38:50
我希望構建一個每秒至少可以處理 300-400 個事務的流程/腳本。目前我正在使用 Workerman 來完成以下工作。我可以毫無問題地運行 400 個線程,但 tps 約為 60-70 tps,它可以以不到一秒的延遲進行處理。以下是工作代碼:-現在,當我將線程增加到 800 時,問題就開始了:-Notice: Undefined variable: PAK in test.php.php on line 77PHP Warning:  DOMDocument::loadXML(): Empty string supplied as input in test.php.php on line 69Warning: DOMDocument::loadXML(): Empty string supplied as input in test.php.php on line 69PHP Notice:  Undefined variable: PAK in test.php.php on line 77Notice: Undefined variable: PAK in test.php.php on line 77PHP Warning:  DOMDocument::loadXML(): Empty string supplied as input in test.php.php on line 166Warning: DOMDocument::loadXML(): Empty string supplied as input in test.php.php on line 166PHP Notice:  Undefined variable: resultCode in test.php.php on line 182Notice: Undefined variable: resultCode in test.php.php on line 182PHP Warning:  DOMDocument::loadXML(): Empty string supplied as input in test.php.php on line 185Warning: DOMDocument::loadXML(): Empty string supplied as input in test.php.php on line 185PHP Notice:  Undefined variable: PAK_checking in test.php.php on line 197Notice: Undefined variable: PAK_checking in test.php.php on line 197PHP Notice:  Undefined variable: psetdatelist in test.php.php on line 198Notice: Undefined variable: psetdatelist in test.php.php on line 198PHP Warning:  DOMDocument::loadXML(): Empty string supplied as input in test.php.php on line 166Warning: DOMDocument::loadXML(): Empty string supplied as input in test.php.php on line 166PHP Notice:  Undefined variable: resultCode in test.php.php on line 182我檢查了一下,當我增加工作人員數量時,CURL XML 似乎是空的。但當 http_worker 為 400 時,就完全沒有問題了。我在虛擬機中運行 8 核 CPU 和 16GB RAM。我的目標是處理來自北行的盡可能多的請求,并以至少 300 TPS 的速度檢查南行。工藝流程如下:-客戶端 -> Main.php -> 檢查南向 -> 生產到 Kafka Topic問題:當我從 400 個線程增加到 800 個線程時,我面臨的問題是,我的curl 響應始終為空。有沒有什么方法可以讓我至少發送 300 tps 并且 XML 解析它而不會出現任何問題?或者有什么建議可以幫助我改進我的流程嗎?
查看完整描述

1 回答

?
慕妹3242003

TA貢獻1824條經驗 獲得超6個贊

我發現 Unix 操作系統在處理超過 200-300 tps 的多個請求時有限制。

我找到了另一種使用 guzzleHTTP 的替代方案,這對我有幫助。它幫助我實現了 600 tps 以上,交易延遲為 2 秒。


查看完整回答
反對 回復 2023-11-03
  • 1 回答
  • 0 關注
  • 247 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號