我想提高我的网络服务器的吞吐量。但是当我用高负载测试它时,我不明白到底发生了什么。
我在一台带有webflux cpu的计算机上运行spring spring boot 2.0.2, netty应用程序。
我用以下代码创建了一个简单的控制器:
@GetMapping("/test-delay")
public Mono<String> testGetWithDelay() throws InterruptedException {
Thread.sleep(3000);
return Mono.just("current time:" + LocalDateTime.now());
}"Thread.sleep(3000)" --它是对同步工作的模仿。然后,我使用100个线程运行jmeter tests。我看到吞吐量仅为2.5 message/sec。我想应该是100 messages/3 sec (大约30条消息/秒)。
所以,我有两个问题:
谢谢
发布于 2018-05-16 07:31:56
你的结果是正确的您可以得到2.5秒的消息,延迟3秒(在每个线程中),这给了我们2.5 * 3 = 7.5 = 8内核。网络流量默认使用availableProcessors()作为处理网络/工作IO的默认线程数。
因此,您需要做的是increase the number of processing threads或移动Thread.sleep(3000)块来分离ThreadPool/Executor (这样工作线程不会被阻塞),或者您的Thread.sleep(3000)代码应该在某种类型的非阻塞API中执行(例如,在网络流量中,您可以使用Mono.fromCallable)。
我建议您使用第二/第三种方法,因为不应该阻止非阻塞API。
https://stackoverflow.com/questions/50362871
复制相似问题