-
-
Notifications
You must be signed in to change notification settings - Fork 141
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
Streaming large files #13
Comments
Not compressing the file before checking if it would fit in the cache in a compressed state fixed this. |
This is a great project! I really love all the built-in features. Unfortunately, this issue has re-emerged. It looks like the server is completely loading the file into some kind of cache or a buffer before sending it to the client: https://github.com/xyproto/algernon/blob/master/engine/handlers.go#L369 Shouldn't all static files be streamed directly from the disk to the client? (That's the default behaviour for all of the other webservers I've used.) Additionally, files that are already compressed (eg: zip, jpg, mp4, ogg, etc.) can be streamed directly to the client without gzipping. Could we have a function that streams static files? |
Thanks for reporting. I suspect that the streaming issues are in debug mode only. Could you please try the |
Same issue. Strangely, the process also balloons up to many multiples of the size of the file it's serving. When I first start algernon, the process uses 293MB of memory. Then I load a 75MB video, and the process's memory usage grows to 771MB. Is algernon is copying the memory block as it's being passed around between functions? Would it be a large architectural change to pass a file handle as a response, and have that stream to the client? |
I will create a reproducible test case and then fix this. |
I am able to reproduce the issue. |
The issue is that this line is trying to read in the entire file: I need to change the code to only read the file if:
|
Added a fix to |
Just tested it: When I try to get a big file, this happens:
|
Thanks for testing. I will add a better test and fix this. |
I updated Algernon to be able to stream large files. I tried both with your test case and the regression test. Two new flags were also added:
Please test. :) |
Success!!! |
Algernon uses too much memory when serving large files (like 500MB audio files). This might be related to caching. Please fix.
The text was updated successfully, but these errors were encountered: