Closed YunWZ closed 3 years ago
It does not use blocking io. It uses reactor-netty HttpClient underneath. Can you describe your setup more in depth?
It does not use blocking io. It uses reactor-netty HttpClient underneath. Can you describe your setup more in depth?
I create a spring boot application(reactor web service,the spring boot version is 2.3.7.RELEASE, server.port=8081
), and defined a restful api. For example:
@RestController
public class DemoController {
private AtomicInteger times = new AtomicInteger(1);
@GetMapping("/demo/sleep")
public Mono<Void> sleep() throws InterruptedException {
System.out.println("get request:" + times.getAndIncrement());
Thread.sleep(TimeUnit.SECONDS.toMillis(60L)); //This is to simulate a long poll request
System.out.println("end");
return Mono.empty();
}
}
And then created a spring-cloud-gateway application(the spring boot version is 2.3.7.RELEASE, spring-cloud version is Hoxton.SR11, spring-cloud-starter-gateway version is 2.2.8.RELEASE, server.port=8080
).I defined a route like this:
spring:
cloud:
gateway:
routes:
- id: toProxiedService
uri: http://localhost:8081
order: 1
predicates:
- Path=/**
After running these two services,I send 40 requests(http:/localhost:8080/demo/sleep
) to gateway service at the same time by Jmeter,i expacted that the gateway service will forward all requests to the proxied service, but in fact the gateway can only forward 12 requests at the same time
When I send 40 requests at the same time by Jmeter,i found that spring-cloud-gateway can only forward 12 requests at the same time(the gateway server has 12 "reactor-http-nio-*" threads) and the remaining requests will not be processed until proxied server return responses.
In my proxied server, i defined an api:
In my gateway server,i configured route: