How can I work with very large file uploads on the Erlang web server?

So let's say I'm writing a web server, and I want to support "very large" file downloads. Suppose further that I want to do this through the standard MIME type multipart / form-data. I have to say that I use erlang and plan to collect http packets as they come back from erlang:decode_packet/2, but I don't want to actually collect the request body until the HTTP request handler finds a place for the downloaded content to go. Should I

a) go ahead and collect the body in any case, ignoring the possibility of its very large and, possibly, server crash due to its lack of memory?

b) refrain from receiving any (possibly non-existent) request authority on the socket until the header handlers are processed?

c) do something else?

An example of a c response might be: create another process to collect and write downloaded content to a temporary location (to minimize memory usage), while providing this location to the HTTP request handler for further processing. But I just don’t know - is there a standard technique here?

+5
source share
3 answers

In my opinion, option b is clearly superior to one.

, , TCP . TCP HTTP-, ( TCP ), TCP .

, , TCP .

+2

c - . , afaik yaws simillar - yaws/src/yaws_multipart.erl

0

, PHP , . , , .

0

All Articles