-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
WebFlux non-streaming JSON array response is flushed after every value #33224
Comments
Thanks for the repro, in your use case Could you please share more on how you identify that flushing happens after each element returned by a |
By looking at the network traffic. Attaching two capture files:
|
@violetagg @rstoyanchev Is it expected that Reactor Netty flushes on every
|
@0xabadea Please enable
|
Attaching the wiretap logs. @violetagg, could you please advice? How do you suggest I should change the publisher to publish in a more effective manner than 1 by 1? Eventually, |
This change was made in #28398. In your case with lots of small items, it makes sense to aggregate, but in other cases it is better to stream. After the change we don't aggregate by default, but you can still choose to aggregate by using |
@0xabadea In the provided logs, I can see, that sometimes we flush many |
Thank you for the pointer to
I tried both |
@0xabadea I assume that you are using HTTP/1.1 (if that's not the case please tell me). Try the following: |
@violetagg Indeed, at least the reproducer uses HTTP/1.1. I have followed your yesterday's suggestion, but unfortunately I got the same behavior of many small flushes. |
@0xabadea Then I will need some example project to play with it. |
An example project is attached to the original description. The only change I made to it is adding
|
@0xabadea Yeah you are right - in your case |
I am going to close this now as this is out of scope of this project. Thanks @violetagg for following up. |
We have an endpoint like this:
In our use case this endpoint can return tens of thousands of values. In production we see that all responses are
flushed often, most of the time after each value is written. These values can be quite small, so flushing after each results in many small packets, which is wasteful due to TCP/IP bookkeeping and a poor use of the connection bandwidth.
This is not a streaming use case. The way the code is written implies that flushing after each value is not intentional:
ReactorServerHttpResponse.writeWithInternal
is called, as opposed towriteAndFlushWithInternal
.I was not able to reproduce the behavior by simply returning the values from memory. I could only reproduce when streaming data from the database, in our case PostgreSQL. I'm attaching a simple demo project, which on my machine reproduces the flushing consistently. Start the application and run
demo-flush.zip
Spring Boot version: 3.3.1
The text was updated successfully, but these errors were encountered: