Replies: 2 comments 1 reply
-
While I don't doubt that there are performance issues, I always thought the bigger issue was security. Things like |
Beta Was this translation helpful? Give feedback.
-
Performance really is the biggest issue with regards to serving static files from Node.js. The bottleneck is largely due to the way Node.js reads and flows data through the system. Consider this: When you use the async file system APIs to read a file, each individual read is deferred to the libuv thread pool, queued by the event loop for processing, marshalled across the C++/JavaScript boundary, passed into JavaScript operations to possibly be manipulated by user code, then passed back out to the http socket which marshals each chunk back across the C++/JavaScript boundary and back down to libuv for sending. It's a significant amount of additional overhead. If we happen to layer TLS into that flow as well it just becomes more expensive. |
Beta Was this translation helpful? Give feedback.
-
I have seen numerous recommendations online for running NGINX as a caching RP in front of node, so that node doesn't have to server static files... because it is bad at it, but never really an explanation as to why...
Some of the older posts mention things like readFile in express-static (which now pipes the stream), but most posts just say "use nginx".
I'd really like to understand why, and to understand the metrics I'm seeing in my current benchmark.
I am seeing relatively low cpu/memory/network utilization, (8 core, 16G mem EC2 instance) with a simple static server using cluster to use n-1 forks and serving up pre-compressed gzip files from the filesystem.
I'm at a loss for where the bottleneck is here... any tips?
Beta Was this translation helpful? Give feedback.
All reactions