Alex Rivera | Logout

Event loop for large files?

Asked 2011-08-03T12:51:37.740
9

If I'm not mistaken, I remember the "event loop" model of asynchronous I/O (Node.js, Nginx) not being well-suited for the sake of serving large files.

Is this the case, and if so, are there methods around it? I'm considering writing a real-time file explorer / file server in Node, but files could be anywhere from 100MB to ~3GB. I would assume that the event loop would block until the file is completely served?

Edit
Report

1 Answer

2

If I'm not mistaken, I remember the "event loop" model of asynchronous I/O (Node.js, Nginx) not being well-suited for the sake of serving large files.

I think you stand correct that node.js is not optimized for serving big files. I advice you to have a look at Ryan Dahl's slides. Especially

Slide 14

Wow. Node sucks at serving large files. Well over 3 second responses for 256 kilobyte files at 300 concurrent connections.

Slide 15

What’s happening: V8 has a generational garbage collector. Moves objects around randomly. Node can’t get a pointer to raw string data to write to socket.

Slide 21

But the fact remains, pushing large strings to socket is slow.

Hopefully this can be mitigated in the future.

are interesting. Maybe this has changed, but I think it would probably be better to use NGinx to serve your static files(or maybe a CDN). I think you are misinformed that NGinx is bad at serving large files. Node.js is(was) a bad at this because of V8 garbage collection, not because of event-loop. Also this link might be interesting.

answered 2011-08-03T17:53:31.517

Your Answer