简体   繁体   English

Ubuntu 14.04 nc 100%CPU使用率

[英]Ubuntu 14.04 nc 100% CPU usage

I am using Ubuntu 14.04 server (8 cores, 16 GB RAM) for hosting a PHP website, MySQL and Redis. 我使用Ubuntu 14.04服务器(8核,16 GB RAM)来托管PHP网站,MySQL和Redis。 PHP web and MySQL has very low traffic (MySQL: Queries per second avg: 0.825). PHP Web和MySQL的流量非常低(MySQL:每秒查询数:0.825)。 Redis processes 8011 commands per second. Redis每秒处理8011个命令。

Today I have noticed that nc stays in the top of top : 今天我注意到nc仍top

8348 root      20   0   11224    764    624 R 100.0  0.0   2277:01 nc                                                                                                                            
8319 root      20   0   11224    760    624 R 100.0  0.0   2277:59 nc                                                                                                                        
8324 root      20   0   11224    764    624 R 100.0  0.0   2278:09 nc                                                                                                                        
8344 root      20   0   11224    760    624 R 100.0  0.0   2277:07 nc

Stracing nc gives: Stracing nc给出:

root@host:/home/user# strace -p 8348
Process 8348 attached
poll([{fd=3, events=POLLIN}, {fd=-1}], 2, 1000) = 1 ([{fd=3, revents=POLLERR}])
poll([{fd=3, events=POLLIN}, {fd=-1}], 2, 1000) = 1 ([{fd=3, revents=POLLERR}])
poll([{fd=3, events=POLLIN}, {fd=-1}], 2, 1000) = 1 ([{fd=3, revents=POLLERR}])
intentionally cutted N lines from output

A quick lookup on man poll gives me info that poll waits for one of a set of file descriptors to become ready to perform I/O. 快速查找man poll poll waits for one of a set of file descriptors to become ready to perform I/O.有关poll waits for one of a set of file descriptors to become ready to perform I/O.

How do I find out what is happening to file descriptors (is it file descriptors issue?) and fix nc eating up 100% CPU? 我如何找出文件描述符发生了什么(文件描述符问题?)并修复nc占用100%CPU?

We had a similar issue recently. 我们最近遇到了类似的问题。 We have a cron job that sends some redis stats to graphite over udp via netcat , and after bringing one of our graphite hosts down for a while last week, we noticed that CPU usage on our redis boxes skyrocketed. 我们有一个cron作业通过netcat将一些redis统计信息发送到udp上的石墨,并且在上周将我们的一个石墨主机关闭了一段时间之后,我们注意到我们的redis盒子上的CPU使用率暴涨。 It appears to be a bug in netcat : https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=752931 它似乎是netcat一个错误: httpsnetcat netcat = netcat

The command we were running was something like this: 我们运行的命令是这样的:

echo "{redis_metric}" | nc -w 1 -u ${graphite_host} 8125

Using the 'quit' option (-q), as opposed to the 'timeout' option (-w), seems to fix the issue for us: 使用'quit'选项(-q)而不是'timeout'选项(-w),似乎可以解决我们的问题:

echo "{redis_metric}" | nc -q 1 -u ${graphite_host} 8125

Hope that helps! 希望有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM