Spring Boot - Limit on number of connections created

后端 未结 5 1156
轮回少年
轮回少年 2020-12-12 23:43

I developed a microservice using Spring Boot. I was performance testing the service by stubbing the backend calls. When I looked at the thread count , I see that the maximu

5条回答
  •  醉梦人生
    2020-12-13 00:37

    Increase maxConcurrentStreamExecution (set 200) for HTTP/2 in Spring Boot 2:

    @Bean
    public WebServerFactoryCustomizer containerCustomizer() {
        return new WebServerFactoryCustomizer() {
            @Override
            public void customize(TomcatServletWebServerFactory factory) {
                factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
                    @Override
                    public void customize(Connector connector) {
                        Arrays.stream(connector.getProtocolHandler().findUpgradeProtocols())
                            .filter(upgradeProtocol -> upgradeProtocol instanceof Http2Protocol)
                            .map(upgradeProtocol -> (Http2Protocol) upgradeProtocol)
                            .forEach(http2Protocol -> http2Protocol.setMaxConcurrentStreamExecution(200));
                    }
                });
            }
        };
    }
    

提交回复
热议问题