为什么node使用100%的CPU?
我正在使用 Express Web 框架和 Node.js。
我正在用 ab 做一个简单的测试:
ab -n 1000 -c 100 http://127.0.0.1:3000/
我使用的是 Express 的默认中间件,只有一个 get()
app.get('/', function(req, res){
res.send("hello");
});
如何才能以 100% 加载 CPU,这不是真正的异步吗?
谢谢
i'm using Express web framework and Node.js.
I'm doing a simple test with ab:
ab -n 1000 -c 100 http://127.0.0.1:3000/
i'm using the default middleware of Express and only one get()
app.get('/', function(req, res){
res.send("hello");
});
how can load the CPU at 100%, is not really async ?
THANK YOU
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅仅因为某些东西是异步的,并不意味着它无法使用所有可用的处理资源。让我们看看您的示例服务器:
当您请求 ab 向示例应用程序发出 100 个并发请求时,显然 CPU 利用率将达到 100%,因为 Node 正在尝试尽快满足这些请求。仅仅因为它是异步的,并不意味着它不会尽力执行您告诉它的操作。
Just because something is asynchronous, doesn't mean that it is incapable of using all processing resources available. Let's look at your sample server:
When you request ab to make 100 concurrent requests to your sample app, you're obviously going to spike 100% CPU utilization, because node is trying to satisfy those requests as quickly as it can. Just because it's asynchronous, doesn't mean it isn't going to work as hard as it can to do what you tell it to.