【问题标题】:Spring WebFlux WebClient resilience and performanceSpring WebFlux WebClient 弹性和性能
【发布时间】:2017-08-25 00:06:30
【问题描述】:

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

场景:

  • 有休息阻塞端点,速度很慢 - 每个请求需要 200 毫秒。
  • 还有其他客户端应用程序,它们调用此慢速端点。

我已经使用 WebFlux - WebClient、Ratpack 和 Lagom 测试了当前(阻塞)Spring Boot 客户端 (tomcat)、Spring Boot 2.0 (netty)。 在每种情况下,我都通过加特林测试简单场景(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));
}
}

我不知道出了什么问题,或者当前的快照版本可以正常工作。

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

  • blocking-service - 慢速阻塞端点
  • 非阻塞客户端 - 基于 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 相同等。

【问题讨论】:

标签: java spring spring-boot nonblocking spring-webflux


【解决方案1】:

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

我还使用 Spring Boot 2.0.0.M4 进行了测试 - 现在一切正常。

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

【讨论】:

  • 当你说现在一切都好。使用 webclient 时,您能否指出与 reactor-netty 中的连接池相关的正确文档。
猜你喜欢
  • 2018-05-09
  • 1970-01-01
  • 2021-09-26
  • 2018-08-18
  • 2021-08-23
  • 1970-01-01
  • 1970-01-01
  • 2017-12-31
  • 2021-08-06
相关资源
最近更新 更多