Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7067387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:11:46+00:00 2026-05-28T05:11:46+00:00

We are trying to serve as much requests as possible, and write one file

  • 0

We are trying to serve as much requests as possible, and write one file per request. With small payload works fine, but on high payload scenarios while the synchronous version still working fine, the asynchronous version (fs.writeFile) hangs. Node stops serving requests and leave most of the files with 0-size (most of them neither get created).

There is no error in v0.6.6

In v.0.4.7 we got:

{ stack: [Getter/Setter],
arguments: undefined,
type: undefined,
message: 'EMFILE, Too many open files \'aw_1031\'',
errno: 24,
code: 'EMFILE',
path: 'aw_1031' }

Same behaviour in Ubuntu(VM) and Mac Osx.

This is the example script we are currently running with:

ab -n 30000 -c 500 http://HOST:8000/

filetest.js

var http = require('http');
var fs = require('fs');
var util = require ('util');
var i=0;

function writeALot(req, res){
    fs.writeFile("filetest"+i, "Just a try: "+i,
        function(err){
            if(err)    console.log(util.inspect(err));
        });
    i++;
    res.writeHead(200);
    res.end();
}
http.createServer(writeALot).listen(8000);

How can we manage the max number of concurrent fd? Any advice?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:11:47+00:00Added an answer on May 28, 2026 at 5:11 am

    Well the number of file descriptors are limited(http connections are file descriptors too). Here with every connection, one file would be written, which will be 1000 file descriptors at 500 concurrency. And probably your ulimit -n is 1024. You can increase the limit actually, which I’ve seen people doing for production high concurrency servers. Beside that you can make a queue with a concurrency less than 500. I did this in one of my apps using async module. Putting a cap on every request I make. This will hold the file descriptors that I’m making, but not the incoming connections.

    var queue = async.queue(function(task, cb) {
        console.log('processing', task.method, queue.length(), task.addr)
        if(task.method === 'file') {
            makeFileStream(task);
        } else {
            makeRequest(task);
        }
    }, 500);
    

    Then later on, if I want to make a request or open a file,

    queue.push({
      method : 'file', // or request
      task : 'something'
    });
    

    There is also this way: http://nodebits.org/distilled-patterns

    But the example of batch processing is not nice as using a queue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to serve a pdf file from a database in ASP.NET using an
I'm trying to use Mechanize to capture a POST request which is not possible
I'm trying to get a JSONP AJAX request to go through, but I'm having
I'm trying to find out how much memory my own .Net server process is
I've Google around and haven't found much... I'm trying to run script/server for my
So I am trying to serve large files via a PHP script, they are
I am trying to serve a svg map using: <object data=map.svg type=image/svg+xml width=400 height=300>
I'm trying to serve a property list of search results to my iPhone app.
I'm trying to build a blog/messageboard that uses static HTML files to serve content.
I'm trying to create a custom transition, to serve as a replacement for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.