-
Notifications
You must be signed in to change notification settings - Fork 44
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
Lack of backpressure when client code does not schedule read (httpaf-lwt-unix) #140
Comments
Looks like this issue is not Lwt specific though. Buffer gets pushed to |
Part of the contract of I think the way to handle back pressure (which never happens right now, kind by design), is to have the reader be active when there's a read scheduled. If there isn't one scheduled, then the Or something along those lines. |
After some time of looking at the code I'm still unable to find the relevant places for such a change :( So far I've worked around this by using Lwt_mutex which gets blocked in the request handler while it's waiting for data to be processed. Same mutex is being blocked by Lwt adapter layer when it tries to push the next buffer to httpaf. Albeit being slow, it works as a flow control. |
So as I understood right now reader never yields when request is not finished |
So apparently `Httpaf.Body.schedule_read` reuses the same buffer that it passes to the `on_read` callback, so you have to copy it if you want to keep the original one. See inhabitedtype/httpaf#140 (comment)
So apparently `Httpaf.Body.schedule_read` reuses the same buffer that it passes to the `on_read` callback, so you have to copy it if you want to keep the original one. See inhabitedtype/httpaf#140 (comment)
/cc @aantron
I've modified lwt_echo_post example as follows:
Upload large file to this app:
Expected behavior would be to stop consuming data from the socket as there's nowhere to feed it, but that's not the case. I've instrumented
read
function from httpaf_lwt_unix.ml with a print like this:During upload print statement executes constantly, memory footprint grows until full request is buffered in memory. Response is being sent back slowly due to delay as expected.
The text was updated successfully, but these errors were encountered: