如何调试引起100%cpu使用率的node.js? [英] how to debug node.js causing 100% cpu usage?
问题描述
我有一个使用Express和Redis的节点应用程序。在我们的开发服务器上,使用点节点开始使用100%cpu。该应用程序仍会响应,但是使用100%的顶级报告节点。直到重新启动节点后,CPU才会掉线。
I have a node app that uses express and redis. On our development server, after a bit of use node starts to use 100% cpu. The application still responds but top reports node using 100%. The cpu doesn't drop until node is restarted.
我还没有将它固定到任何导致它的特定路由或功能上。
I have not nailed it down to any particular route or function that is causing it.
诊断此问题的最佳方法是什么?
What is the best way to diagnose this problem?
我用v8-profiler查看了节点检查器,它给了我与此处报告的相同错误
https://github.com/dannycoates/v8-profiler/issues/10
I looked at node-inspector with the v8-profiler and it gave me the same error that is reported here https://github.com/dannycoates/v8-profiler/issues/10
推荐答案
您可以使用 node-tick配置应用程序。
- 通过
node-tick
> sudo npm -g install tick - 使用启用的配置文件
node --prof ./app.js$c运行您的应用程序$ c>
- 使用CPU 100%使用一段时间后,停止应用程序
- 您可以在应用程序目录中看到v8.log,现在您可以用node-tick-processor读取它
- 运行
node-tick-processor
并解释结果 - 将v8.log加载到chrome:// tracing中以作为树进行分析。
- Install
node-tick
bysudo npm -g install tick
- Run your app with enabled profile
node --prof ./app.js
- After some time with CPU 100% usage stop your app
- You can see v8.log in your app directory, now you can read it with node-tick-processor
- Run
node-tick-processor
and explain results - Load v8.log into chrome://tracing to analyse as tree.
这篇关于如何调试引起100%cpu使用率的node.js?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!