使用NodeJS child_processes.spawn运行脚本时打开的文件太多 [英] Too many open files when using NodeJS child_processes.spawn to run scripts

查看:340
本文介绍了使用NodeJS child_processes.spawn运行脚本时打开的文件太多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用主脚本生成可变数量的子进程可变次数,以便针对服务器执行负载测试。

Using a master script to spawn a variable number of child processes a variable number of times in order to perform load testing against a server.

主脚本最初会生成所有可能的子代(根据其配置设置),然后,如果子代进程退出(如果配置请求运行的次数更多),则会启动新的子代。

The master script initially spawns all the children it can (according to its configuration settings) and then as the children processes exit if there are more runs requested by the config then new children are spun up.

我没有做任何事情来明确关闭在子代生成过程中打开的文件,但是大概这不是打开代码的工作,而是child_processes模块代码的工作?

I'm not doing anything to explicitly close the files opened as part of the child spawning process but presumably that's not the job of the opening code but the child_processes module code?

我很好奇82个子进程的数量。

I'm very curious about the magic number of 82 child processes. This seems to indicate something about either a limitation in node or some combination of node on my system?

我还对了解NodeJS即将使用的Web Worker API的状态感兴趣。有人知道吗?

I'm also interested in learning about the status of the Web Worker API that is coming to NodeJS. Anyone know anything about that?


  • NodeJS v0.4.7

  • Mac OS X v10.6.7

  • ulimit -n = 256

  • 可以成功运行的神奇子代数量= 82
    (表示产生了82个以上的proc会引发打开文件太多错误)

  • NodeJS v0.4.7
  • Mac OS X v10.6.7
  • ulimit -n = 256
  • magic number of spawned children that will run successfully = 82 (meaning that > 82 spawned procs will throw the "too many open files" error)

感谢您的帮助。

推荐答案

我的猜测是系统正在完全按照您所说的进行。 82个进程是每个进程3个打开的文件。 STDIN,STDOUT,STDERR。砰。您只需使用标准3个文件描述符即可达到ulimit。使用ulimit -n 512运行,我敢打赌,您将可以运行两倍多的孩子。

My guess is the system is doing exactly what you are telling it. 82 processes is 3 open files per process. STDIN, STDOUT, STDERR. Bang. You've hit your ulimit just with the standard 3 file descriptors. Run with ulimit -n 512 and I bet you'll be able to run twice as many children.

这篇关于使用NodeJS child_processes.spawn运行脚本时打开的文件太多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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