hyperf kafka多进程消费者,消耗cpu100%的问题
想请教一下我使用了 hyperf
中的 kafka
组件,开了三个消费者进程,一个消费者的cpu消耗是15左右,另外两个一直都是100,这个是有问题的吗?是不是我有什么地方没有配置对呢?我该如何确定我两外两个进程是否有在工作呢
补充一下配置文件以及消费者的逻辑代码
kafka.php
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
use Hyperf\Kafka\Constants\KafkaStrategy;
return [
'default' => [
'connect_timeout' => -1,
'send_timeout' => -1,
'recv_timeout' => -1,
'client_id' => '',
'max_write_attempts' => 3,
'bootstrap_servers' => [
'127.0.0.1:9092',
],
'acks' => -1,
'producer_id' => -1,
'producer_epoch' => -1,
'partition_leader_epoch' => -1,
'interval' => 0,
'session_timeout' => 60,
'rebalance_timeout' => 60,
'replica_id' => -1,
'rack_id' => '',
'group_retry' => 5,
'group_retry_sleep' => 1,
'group_heartbeat' => 3,
'offset_retry' => 5,
'auto_create_topic' => true,
'partition_assignment_strategy' => KafkaStrategy::RANGE_ASSIGNOR,
'sasl' => [
],
'ssl' => [
],
'pool' => [
'min_connections' => 1,
'max_connections' => 10,
'connect_timeout' => 10.0,
'wait_timeout' => 3.0,
'heartbeat' => -1,
'max_idle_time' => 60.0,
],
],
];
消费者的逻辑
100%肯定是不正常的,但是你提供的信息也太少了,配置,日志信息都没有提供,不知道咋帮你看
100% 肯定是出现死循环了,贴代码吧
我把配置中的
'interval' => 0,
改为 1 就好了