美文网首页
SpringCloud Gateway 2.x 并发调优

SpringCloud Gateway 2.x 并发调优

作者: BeRicher | 来源:发表于2020-05-12 13:46 被阅读0次

由于2.x gateway 使用的是netty。

要设置起本身可同时工作的线程数需要设置netty中的 reactor.netty.ioWorkerCount 参数。

该参数无法直接配置,需要通过System.setProperty设置,故我们可以创建以下配置类来配置该参数:

    @Configuration
    public static class ReactNettyConfiguration {
        @Value("${reactor.netty.worker-count}")
        private String workerCount;

        @Bean
        public ReactorResourceFactory reactorClientResourceFactory() {
            System.setProperty("reactor.netty.ioWorkerCount", workerCount);
            return new ReactorResourceFactory();
        }
    }

此时我们便可以在yaml文件中通过以下方法配置工作线程数

react:
    netty:
        worker-count: 1

其他的netty参数同样可以以这样的方式进行配置

相关文章

网友评论

      本文标题:SpringCloud Gateway 2.x 并发调优

      本文链接:https://www.haomeiwen.com/subject/hejbnhtx.html