Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SizeLimit middleware performance and memory issues #16

Closed
umputun opened this issue May 14, 2021 · 0 comments
Closed

SizeLimit middleware performance and memory issues #16

umputun opened this issue May 14, 2021 · 0 comments

Comments

@umputun
Copy link
Member

umputun commented May 14, 2021

As reported here the performance of the size limiter not that good for huge requests. This is unlikely even noticeable for a typical request, but in the case of uploading file chunks it is problematic

The current method uses LimitReader to get the allowed part of the request and serves it from bytes buffer after the read. Actually, I'm not even sure why it's causing such a delay. I suspect some deficiency of the testing method, i.e. with size limiter in place the actual read of the data enforced, but maybe without it that read just skipped

Anyhow, for large limits the current approach may utilize a lot of memory, even if the performance problem is not real. Probably the better way to deal with this is to hijack the response writer and deal with the limit on the writer level

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant