Node.js 的 http.request 的性能如何?它可以处理多少并发请求? [英] What is the performance for Node.js' http.request ? How many concurrent request it can handle?

查看:116
本文介绍了Node.js 的 http.request 的性能如何?它可以处理多少并发请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 node.js 服务器正在使用最新的 (0.4.8) http.request 调用调用另一台服务器.

My node.js server is making a call to another server using the latest (0.4.8) http.request call.

我使用 jMeter 来运行负载测试.每秒 50-100 个并发线程,循环 1000 次.

I use jMeter to run load testing. with 50-100 concurrent threads per sec, and loop 1000 times.

当脚本继续运行时,我发现速度有些慢.我监控网络吞吐量很低,CPU &内存也低.而在另一台服务器中,日志显示他们的响应很快.(毫秒内).

I observe some slow down when script keeps running. I monitor the network throughput is pretty low, CPU & memory are low too. And in the other server, the log shows that their response is quick. (within millisecond).

然而,我的 node.js 服务器中的 console.log 显示 http.request 响应时间从 200-300 毫秒开始,到 2000-3000 毫秒.

however, the console.log in my node.js server shows that the http.request response time begins with 200-300 ms, to 2000-3000 ms.

我不确定并发 http.request 是否有限制.

I'm not sure if there is a limit of concurrent http.request I can make.

请指教.

经过大量测试,我认为 http.request 的平均请求/秒约为 300-400 请求/秒,服务器正常,maxSockets = 1024.通常,我看到速度(连接到不同网站)约为 80-100 毫秒每个请求.

After tremendous testing, I think the average is about 300-400 request / sec for http.request with a ok server, maxSockets = 1024. Usually, I see the speed (connect to different website) is about 80-100 ms per request.

推荐答案

最大并发连接数应该取决于您的硬件.这篇文章说node.js可以支持几万个并发连接.但是,大多数 linux 系统默认只允许您同时打开 1024 个文件/套接字.对于这种情况,您可以以 root 身份运行,然后将 ulimit 设置为一个大数字(例如,100000),然后对您的硬件进行压力测试以获得准确的并发连接容量.

The max concurrent connections should depends on your hardware. This article said node.js can support tens of thousands of concurrent connection. However, most linux systems only allow you open 1024 files/sockets on same time by default. For that case, you can run as root and then set ulimit as a big number(e.g., 100000), then run a stress test with your hardware for getting the accurate capacity of concurrent connection.

这篇关于Node.js 的 http.request 的性能如何?它可以处理多少并发请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆