CPU占用高, 一直持续占用40%左右

qq7467466

问题描述

用jmeter 压测了一下api, 结果导致CPU占用高, 一直持续40%左右, 业务早已执行完毕, 一个小时后还是40%左右, api接口很简单, 就是向kafka 发送一条数据,也没有循环等业务场景

执行status命令

Workerman[start.php] status 
----------------------------------------------GLOBAL STATUS----------------------------------------------------
Workerman version:4.1.10          PHP version:7.4.33
start time:2023-06-27 11:16:47   run 0 days 2 hours   
load average: 4.67, 3.52, 3.48   event-loop:\Workerman\Events\Event
4 workers       27 processes
worker_name                                             exit_status      exit_count
CloudEvents                                             0                0
monitor                                                 0                0
----------------------------------------------PROCESS STATUS---------------------------------------------------
pid memory  listening           worker_name                                             connections send_fail timers  total_request qps    status
2522    10.73M  http://0.0.0.0:8585 CloudEvents                                             0           0         3       261           0      [idle]
2523    10.74M  http://0.0.0.0:8585 CloudEvents                                             0           0         3       259           0      [idle]
2524    10.74M  http://0.0.0.0:8585 CloudEvents                                             0           0         3       257           0      [idle]
2526    10.7M   http://0.0.0.0:8585 CloudEvents                                             0           0         3       259           0      [idle]
2529    10.75M  http://0.0.0.0:8585 CloudEvents                                             0           0         3       260           0      [idle]
2531    10.73M  http://0.0.0.0:8585 CloudEvents                                             0           0         3       271           0      [idle]
2533    10.7M   http://0.0.0.0:8585 CloudEvents                                             0           0         3       260           0      [idle]
2534    10.76M  http://0.0.0.0:8585 CloudEvents                                             0           0         3       353           0      [idle]

执行strace命令

strace -ttp 2523

strace: Process 2523 attached
13:30:35.333804 epoll_wait(3, [], 32, 2767) = 0
13:30:38.103431 sendto(12, "\t\0\0\0\26select 1", 13, MSG_DONTWAIT, NULL, 0) = 13
13:30:38.103876 poll([{fd=12, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=12, revents=POLLIN}])
13:30:38.104871 recvfrom(12, "\f\0\0\1\0\217\4\0\0\1\0\0\0\0\0\0\27\0\0\2\3def\0\0\0\0011\0\f?"..., 32768, MSG_DONTWAIT, NULL, NULL) = 52
13:30:38.105399 sendto(12, "\n\0\0\0\27\217\4\0\0\0\1\0\0\0", 14, MSG_DONTWAIT, NULL, 0) = 14
13:30:38.108182 poll([{fd=12, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=12, revents=POLLIN}])
13:30:38.108447 recvfrom(12, "\1\0\0\1\1\27\0\0\2\3def\0\0\0\0011\0\f?\0\1\0\0\0\10\201\0\0\0\0"..., 32768, MSG_DONTWAIT, NULL, NULL) = 64
13:30:38.108532 sendto(12, "\5\0\0\0\31\217\4\0\0", 9, MSG_DONTWAIT, NULL, 0) = 9
13:30:38.108662 epoll_wait(3, 
[], 32, 38276) = 0
13:31:16.423196 poll([{fd=9, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)
13:31:16.424236 sendto(9, "*2\r\n$3\r\nGET\r\n$22\r\nCloudEvents:re"..., 42, MSG_DONTWAIT, NULL, 0) = 42
13:31:16.425206 poll([{fd=9, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 1 ([{fd=9, revents=POLLIN}])
13:31:16.425573 recvfrom(9, "$", 1, MSG_PEEK, NULL, NULL) = 1
13:31:16.425687 poll([{fd=9, events=POLLIN|POLLERR|POLLHUP}], 1, 60000) = 1 ([{fd=9, revents=POLLIN}])
13:31:16.425744 recvfrom(9, "$-1\r\n", 8192, MSG_DONTWAIT, NULL, NULL) = 5
13:31:16.427619 poll([{fd=11, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)
13:31:16.428049 sendto(11, "*2\r\n$3\r\nGET\r\n$24\r\nCloudEvents:se"..., 44, MSG_DONTWAIT, NULL, 0) = 44
13:31:16.428261 poll([{fd=11, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)
13:31:16.428297 poll([{fd=11, events=POLLIN|POLLERR|POLLHUP}], 1, 60000) = 1 ([{fd=11, revents=POLLIN}])
13:31:16.429669 recvfrom(11, "$-1\r\n", 8192, MSG_DONTWAIT, NULL, NULL) = 5
13:31:16.430009 epoll_wait(3, [], 32, 16678) = 0
13:31:33.125197 sendto(12, "\t\0\0\0\26select 1", 13, MSG_DONTWAIT, NULL, 0) = 13
13:31:33.125610 poll([{fd=12, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=12, revents=POLLIN}])
13:31:33.126745 recvfrom(12, "\f\0\0\1\0\220\4\0\0\1\0\0\0\0\0\0\27\0\0\2\3def\0\0\0\0011\0\f?"..., 32768, MSG_DONTWAIT, NULL, NULL) = 52
13:31:33.127238 sendto(12, "\n\0\0\0\27\220\4\0\0\0\1\0\0\0", 14, MSG_DONTWAIT, NULL, 0) = 14
13:31:33.128790 poll([{fd=12, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=12, revents=POLLIN}])
13:31:33.129105 recvfrom(12, "\1\0\0\1\1\27\0\0\2\3def\0\0\0\0011\0\f?\0\1\0\0\0\10\201\0\0\0\0"..., 32768, MSG_DONTWAIT, NULL, NULL) = 64
13:31:33.129171 sendto(12, "\5\0\0\0\31\220\4\0\0", 9, MSG_DONTWAIT, NULL, 0) = 9
13:31:33.129478 epoll_wait(3, [], 32, 38254) = 0
13:32:11.422369 poll([{fd=11, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)
13:32:11.422432 sendto(11, "*2\r\n$3\r\nGET\r\n$24\r\nCloudEvents:se"..., 44, MSG_DONTWAIT, NULL, 0) = 44

执行lsof命令

php     2523 root  172r     FIFO                0,9       0t0    41827 pipe
php     2523 root  173w     FIFO                0,9       0t0    41827 pipe
php     2523 root  174r     FIFO                0,9       0t0    41828 pipe
php     2523 root  175w     FIFO                0,9       0t0    41828 pipe
php     2523 root  176u     IPv4              41830       0t0      TCP localhost.localdomain:8138->192.168.199.131:XmlIpcRegSvc (ESTABLISHED)
php     2523 root  177r     FIFO                0,9       0t0    42680 pipe
php     2523 root  178w     FIFO                0,9       0t0    42680 pipe
php     2523 root  179r     FIFO                0,9       0t0    42681 pipe
php     2523 root  180w     FIFO                0,9       0t0    42681 pipe
php     2523 root  181u     IPv4              40898       0t0      TCP localhost.localdomain:8190->192.168.199.131:XmlIpcRegSvc (ESTABLISHED)
php     2523 root  182r     FIFO                0,9       0t0    41882 pipe
php     2523 root  183w     FIFO                0,9       0t0    41882 pipe
php     2523 root  184r     FIFO                0,9       0t0    41883 pipe
php     2523 root  185w     FIFO                0,9       0t0    41883 pipe
php     2523 root  186u     IPv4              41885       0t0      TCP localhost.localdomain:8224->192.168.199.131:XmlIpcRegSvc (ESTABLISHED)
php     2523 root  187r     FIFO                0,9       0t0    43125 pipe
php     2523 root  188w     FIFO                0,9       0t0    43125 pipe
php     2523 root  189r     FIFO                0,9       0t0    43126 pipe
php     2523 root  190w     FIFO                0,9       0t0    43126 pipe
php     2523 root  191u     IPv4              42802       0t0      TCP localhost.localdomain:8806->192.168.199.131:XmlIpcRegSvc (ESTABLISHED)
php     2523 root  192r     FIFO                0,9       0t0    43141 pipe
php     2523 root  193w     FIFO                0,9       0t0    43141 pipe
php     2523 root  194r     FIFO                0,9       0t0    42820 pipe
php     2523 root  195w     FIFO                0,9       0t0    42820 pipe
php     2523 root  196u     IPv4              42822       0t0      TCP localhost.localdomain:8828->192.168.199.131:XmlIpcRegSvc (ESTABLISHED)
php     2523 root  197r     FIFO                0,9       0t0    38823 pipe
php     2523 root  198w     FIFO                0,9       0t0    38823 pipe
php     2523 root  199r     FIFO                0,9       0t0    38824 pipe
php     2523 root  200w     FIFO                0,9       0t0    38824 pipe
php     2523 root  201u     IPv4              44134       0t0      TCP localhost.localdomain:8864->192.168.199.131:XmlIpcRegSvc (ESTABLISHED)
1212 1 1
1个回答

qq7467466

问题找到了, kafka连接爆了, 用了单例默认后ok了

年代过于久远,无法发表回答
×
🔝