简体   繁体   English

ubuntu 14.04和nodejs上的CPU使用率低

[英]Low CPU usage on ubuntu 14.04 and nodejs

I have two servers running the exact same nodejs application. 我有两台服务器运行完全相同的nodejs应用程序。 I am doing load testing and I can't figure out why one of my servers will not utilize more CPU and RAM. 我正在进行负载测试,无法弄清楚为什么我的一台服务器不会占用更多的CPU和RAM。

It is much slower when load testing yet it is not even close to utilizing all the free CPU and memory. 进行负载测试时,它的速度要慢得多,但还远远不能利用所有可用的CPU和内存。

If I run top during the load test, these are the numbers I am getting 如果我在负载测试中跑得最好,这些就是我得到的数字

 PID  User      PR   NI VIRT    RES     SHR  S   %CPU %MEM  TIME    COMMAND
 1308 ubuntu    20   0 1002524  87508   9788 S   5.3  4.3   0:03.06 nodejs                                                                                                                             
 1307 ubuntu    20   0  925540  75288   9436 S   5.0  3.7   0:02.17 nodejs                                                                                                                             
 1308 ubuntu    20   0  992076  77068   9788 S  14.0  3.8   0:03.48 nodejs                                                                                                                             
 1307 ubuntu    20   0  937140  86904   9436 S   2.7  4.3   0:02.25 nodejs                                                                                                                             
 1308 ubuntu    20   0 1012936  98000   9788 S  14.3  4.8   0:03.91 nodejs                                                                                                                             
 1307 ubuntu    20   0  942940  92644   9436 S   1.0  4.5   0:02.28 nodejs                                                                                                                             
 1307 ubuntu    20   0  943204  92976   9436 S   6.0  4.6   0:02.46 nodejs                                                                                                                             
 1308 ubuntu    20   0 1011764  96804   9788 S   6.0  4.7   0:04.09 nodejs                                                                                                                             
 1307 ubuntu    20   0  933644  83388   9436 S   8.6  4.1   0:02.72 nodejs                                                                                                                             
 1308 ubuntu    20   0 1008720  93556   9788 S   5.3  4.6   0:04.25 nodejs                                                                                                                             
 1308 ubuntu    20   0 1000184  85256   9788 S   8.6  4.2   0:04.51 nodejs                                                                                                                             
 1307 ubuntu    20   0  944092  93988   9436 S   7.6  4.6   0:02.95 nodejs                                                                                                                             
 1307 ubuntu    20   0  941748  91816   9436 S  15.0  4.5   0:03.40 nodejs                                                                                                                             
 1308 ubuntu    20   0 1004832  90008   9788 S   1.3  4.4   0:04.55 nodejs                                                                                                                             
 1307 ubuntu    20   0  933460  82632   9436 S   9.0  4.1   0:03.67 nodejs 

Running two processes I don't see memory getting above 4.7% and CPU is at 14%. 运行两个进程,我看不到内存超过4.7%,CPU为14%。

It is taking twice as long to serve the exact same resources as a machine with one core and half the memory. 提供与拥有一个内核和一半内存的机器完全相同的资源所需的时间是原来的两倍。

My other server is using %52 of CPU. 我的其他服务器正在使用%52的CPU。 Granted it has one core and the above has two, but it doesn't seem like that would make the difference. 虽然它有一个核心,而上面有两个核心,但似乎并没有什么不同。

I downloaded cpufrequtils and set the GOVERNOR to performance but I don't think it is working. 我下载了cpufrequtils并将GOVERNOR设置为性能,但我认为它不起作用。 This is what I get when I run cpufreq-info 这是我运行cpufreq-info时得到的

analyzing CPU 0:
  no or unknown cpufreq driver is active on this CPU
  maximum transition latency: 4294.55 ms.
analyzing CPU 1:
  no or unknown cpufreq driver is active on this CPU
  maximum transition latency: 4294.55 ms.

Here is the CPU 这是CPU

Intel(R) Core(TM)2 CPU          6300  @ 1.86GHz

Any ideas or hints would be appreciated 任何想法或提示将不胜感激

If both servers are running the same node.js application, then you may want to compare the other settings on the machines, are they the same? 如果两个服务器都运行相同的node.js应用程序,那么您可能要比较计算机上的其他设置,它们是否相同? ulimit -a ulimit -a

Also for dual/multicore core machines, node.js is single threaded, it will not benefit from dual/multicores unless you use cluster to make use of it. 同样对于双核/多核核心计算机,node.js是单线程的,除非您使用群集来利用它,否则它将不会从双核/多核中受益。

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

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