-
Notifications
You must be signed in to change notification settings - Fork 40.7k
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
Make Netty HTTP server configurable #10418
Comments
I think additional properties would be sensible. As would some callback for programmatic control (similar to @bclozel do you agree? Would there be any downsides? |
Programmatic callbacks could be useful indeed. Configuration properties for this key, I'm not 100% convinced. Just to have more background on this @florian-stefan, how are you going to achieve progressive rendering? Does your templating engine supports this in any way? Or are you rendering fragments through separate REST API calls? |
@bclozel At the moment, we are using Thymeleaf for defining the layout of the page. Since Thymeleaf does not support progressive rendering, we are fetching the template directly from the template cache, e.g. We achieve streaming by using a simple controller method which returns a
Does this answer your question? |
Thanks for the details @florian-stefan ! The use case you're describing is quite interesting, and there are a few ways to support that.
Thymeleaf may not support "progressive rendering" (I'm not sure what this means), but it offers quite a lot in that space already; for example, you can configure Thymeleaf not to render the whole template as a single buffer but split it with a maximum buffer size; this will limit the amount of in-flight memory, but I'm not sure it controls the flushing as well. Thymeleaf supports advanced scenarios like Server Sent Event or data-driven templates. More on that in this (very interesting) talk. Now you can control the flushing behavior on a per endpoint basis; WebFlux provides One last thing: |
Thank you very much for the input @bclozel (especially for the warning to flush after each chunk on each channel)! You are of course right that this pattern only makes sense for special use cases. But there are scenarios in which it improves the perceived page load time. I will have a look into the (new) Thymeleaf features. At the moment we are experimenting with adapting some patterns from the Play framework to Spring 5. "Progressive HTML Rendering" (Facebook calls it BigPipe) is one example. An implementation using Play is described here. |
@florian-stefan As suggested by @bclozel, don't hesitate to add a comment with more details about your use case and thoughts on SPR-14981, we are looking for this kind of input. |
We want to implement "Progressive HTML Rendering" using Spring Webflux and Reactor. For this, we need to be able to configure the Netty HTTP server so that the underlying channels flush item by item. We are using
spring-boot-starter-webflux
(2.0.0.M3).This can be achieved by setting the attribute
flushOnEach
of theChannelOperationsHandler
totrue
, e.g. by callingNettyPipeline.SendOptions.flushOnEach
after initializing a channel.Unfortunately, the class
NettyReactiveWebServerFactory
does not offer any configuration options. It would be awesome to be able configuring the Netty HTTP Server by setting properties, e.g. in theapplication.yml
.Example: By registering the following bean, we are able to create a working example (for more details see here):
The text was updated successfully, but these errors were encountered: