Spring WebFlux WebClient的弹性和性能

Jak*_*ski 16 java spring nonblocking spring-boot spring-webflux

我只是通过示例PoC项目在简单的常见场景中测试一些阻塞/非阻塞解决方案.

场景:

  • 有一个非常缓慢的休息阻塞端点 - 每个请求花费200毫秒.
  • 还有其他 - 客户端应用程序,它调用这个慢端点.

我已经使用WebFlux测试了当前(阻塞)Spring启动客户端(tomcat),Spring Boot 2.0(netty) - WebClient,Ratpack和Lagom.在每种情况下,我都通过gatling测试简单场景(100-1000个用户/秒)强调了客户端应用程序.

我已经测试了ratpack和lagom作为参考非阻塞io服务器,以将结果与spring boot(阻塞和非阻塞)进行比较.

在所有情况下,我都有预期的结果,除了Spring boot 2.0测试.它仅适用于小负载水平,但即便如此,也具有高延迟.如果负载水平上升 - 所有请求都是时间.

WebClient用法:

@RestController
public class NonBlockingClientController {
private WebClient client = WebClient.create("http://localhost:9000");

@GetMapping("/client")
public Mono<String> getData() {
    return client.get()
            .uri("/routing")
            .accept(TEXT_PLAIN)
            .exchange()
            .then(response -> response.bodyToMono(String.class));
}
}
Run Code Online (Sandbox Code Playgroud)

我不知道出了什么问题或当前的快照版本只是工作.

所有来源均发布于https://github.com/rutkowskij/blocking-non-blocking-poc

  • 阻塞服务 - 缓慢阻塞端点
  • 非阻塞客户端 - Spring Boot 2.0和基于WebClient的客户端

我刚刚使用spring-boot-starter-webflux和版本2.0.0.BUILD-SNAPSHOT创建了一个简单的Spring Boot应用程序,它带来了spring-webflux版本5.0.0.BUILD-SNAPSHOT和Spring Core,Beans,Context等相同.

Jak*_*ski 8

5.0 RC4发布后问题不再存在.该问题与reactor-netty和reactor-core中的连接池有关.

我也用Spring Boot 2.0.0.M4进行了测试 - 现在一切都很好看.

详情:http://jira.spring.io/browse/SPR-15584

  • 当你说现在一切都很好。当使用 webclient 时,您能指出与reactor-netty 中的连接池相关的正确文档吗? (2认同)