If memory is only 1 g, what happens next, like PHP, crashes?
In the case of node. JS, a single process would have a 1G memory limit. What's going to happen, collapse?
Reply content:
PHP seems to actually put the received request body into memory. So in order to avoid trouble, php.ini usually configure the maximum request body size limit, the default is usually 2MB, 4MB and so on, in short. Requests that exceed this limit will be dropped directly by 413.
And if you use node. js, this should depend on the person implementing the HTTP server's own settings. For example, I can write the received data to the hard disk, so as not to occupy the memory:
http.Createserver(function (req, Res) { var FD = FS.OpenSync('/tmp/' + Math.Random(), ' w+ '); req. on(' Data ', function (Chunk) { FS.Writesync(FD, Chunk); }); req. on(' End ', function () { Callbackwithrequestbody(FD); Res.End(); });});
Nodejs buffer memory seems to be another calculation, in addition, this super-large file upload is generally streaming, read how much write, memory consumption is not high. You can use streaming to get the flow of the request, slowly read and write slowly, and node server gets the request itself is to implement the readable stream of things
See Stream node. js v5.1.1 Manual & Documentation
Most web frameworks simply encapsulate the network stream that allows you to not touch the request body directly. No, all is the form of the stream, http/tcp the bottom is the TCP protocol, read and write have a certain buffer, the data or file through the flow of the form of writing to the local