Hi!

I ran into several problems while debuggging a problem at the
customer site related to uploading files and size of those files.

As it looks like, the NS/AS spools all the incoming content into
the memory (urks!). Depending on the content-type, the content
may be parsed, as in case of multipar/form-data.

This is very convenient (you need not fiddle with the low-level
stuff) but it can be extremely inefficient and bloat the memory
footprint of the server if somebody likes to upload 10's or 100's
of MB of data.

I have examined the recent changes in the AS done by Jim which
tackle this issue. He's basically using the "maxinput" config
option to decide wether to stuff everything into memory (as usual)
or, in the case input exceeds the maxinput level,  stuff the
input into a temporary file. But... the programmer is then left
alone and has to parse the incoming input by himself by using
ns_conn contentchannel command to read the content.
Even more, the form machinery which is basically parsing the
multipart data still operates on the connPtr->content which
does not reflect the entire content (the excessive is spooled
into a temp file!).

Hm... this seems pretty unusable for this particular case to me.

Therefore, and as usual, I have a idea/suggestion how to improve
this...

I would take the same direction as Jim did, but will simply mmap the
temp-file to the connPtr->content! This will make all the rest
of the code work as usual. On the connection end, the file will
be unmmaped and there you go.

One can even explore the memmap machinery and see if we can
entirely drop the temp-file and use the system paging for that:
so if the input exceeds the maxinput, we just mmap /dev/zero file
I believe something like that should be possible but will have to
double-check if this is true.

Now, what do you  think?

Zoran


Reply via email to