Skip to content

Conversation

@NelsonVides
Copy link
Contributor

Just like I tried to optimise uploads at elixir-plug/plug#1279, now I want to contribute a bit downloading big files over SSL, as I don't want my server to get OOMed :)

The default chunk-size is 8MB, for no special reason TBH. Ranch uses 8MB if no value is provided (https://github.com/ninenines/ranch/blob/d272ca07524a61000324b2b7f7ad1ce9b2dd1487/src/ranch_transport.erl#L126C4-L126C11), but it also allows to pass opts to the underlying sendfile. Here sendfile takes only four parameters and it just seemed a bit too much to extend the transport interface with a sendfile taking an extra argument with a chunk_size (?)

Also tweaked the tests to use files in binary mode, as they also tend to be more memory efficient.

@NelsonVides
Copy link
Contributor Author

@mtrudel dunno if I should ping you in case you haven't seen it? 🙈

Copy link
Owner

@mtrudel mtrudel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a damned delight! Thanks for this!

@mtrudel mtrudel merged commit d50634a into mtrudel:main Sep 4, 2025
9 checks passed
@NelsonVides NelsonVides deleted the chunk_ssl_sendfile branch September 4, 2025 15:05
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

Successfully merging this pull request may close these issues.

2 participants