为了账号安全,请及时绑定邮箱和手机立即绑定

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 关注
  • 72 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信