nginx: buffer responses in nginx, not application layer - #2036
Conversation
Simplifies test `request()` implementation to use standard `Response` classes. The `request()` function aims to be as similar to `fetch()` as possible, while allowing for non-standard behaviour necessary for tests. Not using `Response` was an oversight in the initial implementation.
My understanding is that if nginx runs out of disk space while trying to buffer a request to disk then that request aborts (ref). We could consider setting Or we keep I don't have a big preference between the two above. Maybe a slight preference for the second because it sticks to defaults, and we can adjust as we learn more about how that behaves. Pverall, his change looks like a good one to me. I really don't understand why the default was overridden in the first place. In the case of a client/connection that can keep up with the application server, nginx will just stream the response out, right? Maybe there's a small difference in time to first byte since it looks like nginx does fill an in-memory buffer before sending: https://mailman.nginx.org/pipermail/nginx/2011-October/029972.html Maybe I do think it would be nice to do a sanity check on e.g. |
Can you expand on this? Because many of the responses are streamed, I don't think any part of the system would know that a response would be over 100MB ahead of time. |
|
@garethbowen when you're back could you please finish this one with @alxndrsn? No blockers from my end, just a couple of suggestions! Can't wait to see the impact it has. |
I think you're correct! I've crossed out that suggestion in the PR description. |
I'm happy with the 1GB default - I think big responses are the main cause of problems when proxy-buffering is disabled. |
garethbowen
left a comment
There was a problem hiding this comment.
The nginx changes are great, more like best practice, and potentially great for performance.
I've got a couple of suggestions for the test that would give me more confidence that we don't regress later...
garethbowen
left a comment
There was a problem hiding this comment.
Comment inline. Mostly I just need to confirm my understanding of how the test works!
Closes #2029
What has been done to verify that this works as intended?
Why is this the best possible solution? Were any other approaches considered?
to avoid resource lock-up for responses over 100MB, they could by rejected by nginxHow does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Does this change require updates to documentation? If so, please file an issue here and include the link below.
No.
Before submitting this PR, please make sure you have:
nextbranch OR only changed documentation/infrastructure (masteris stable and used in production)