Rewrite the multipart/form-data handling under FastCGI #15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This reimplements and optimizes the
ClientFcgi
handling ofCQueryMultipart
messages in FastCGI mode,FastCGI multipart/form-data will be processed until the first
STDIN
message is received, at which point control will be handled to the application. Processing will resume after the application callsneko.Web.parseMultipart
.This follows the behavior of
mod_neko
andmod_tora
.To compensate for the increased complexity, there are also some unit tests.
This PR also incorporates and closes #10; for the record, lower-case headers seem to be sent by some React-Native apps.
Motivation
This PR solves some issues my team and I experienced on a production service that used tora + FastCGI to handle uploads of reasonably sized files.
In comparison with current tora, our requirements were to:
Real world test results
A 7.9 MiB POST outlines the improvements:
neko.vm.Gc.stats()
but a larger 39 MiB POST makes this PR essential:
neko.vm.Gc.stats()
And file sizes greater than 100 MiB generally caused the old (
master
) tora to be terminated by the OOM killer (after nearly exhausting all available memory + swap); in the rare case the request completed, Nginx or the client would have already timed out.Note: the time spent in application space increases with this patch, but that is actually the desired: we're no longer pre-processing a lot of data before starting and handling control to the application.
Metrics:
neko.vm.Gc.stats()
, pretty printedTest case:
multipart/form-data
Configuration:
neko.Web.cacheModule
)master
: 6560e82) vs. after (Rewrite the multipart/form-data handling under FastCGI #15: 9649ca0)