Spring Cloud:Feign和Http连接池 [英] Spring Cloud: Feign and Http Connection Pooling

查看:806
本文介绍了Spring Cloud:Feign和Http连接池的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以告诉我Spring Cloud Feign Client是否提供或支持Http连接池,如果可以的话,如何配置诸如池大小的设置?我似乎在官方文档中找不到此内容.谢谢.

Can anyone please tell me if the Spring Cloud Feign Client provides or supports Http Connection Pooling, and if so how to configure settings like pool size? I can't seem to find this in the official documentation. Thank you.

推荐答案

通过调查,我将尝试回答我自己的问题:

From investigation I will try to answer my own question:

Spring Cloud Feign使用Netflix Feign. Netflix Feign依次使用java.net.HttpURLConnection创建连接,该连接利用了持久连接"而不使用连接池.

Spring Cloud Feign uses Netflix Feign. Netflix Feign in turn creates connections using java.net.HttpURLConnection which makes use of 'persistent connections' but not a connection pool.

可以覆盖客户端,例如改用Apache HttpClient,而Netflix为此提供了一个库(feign-httpclient).使用这种方法时,可以使用SystemProperties设置连接池的大小.

It is possible to override the Client, for example using Apache HttpClient instead, and Netflix provide a library for this (feign-httpclient). When using this approach the connection pool size can be set using SystemProperties.

在Spring Cloud Brixton中,如果Apache HttpClient或OkHttpClient可用(通过@ConditionalOnClass),则它们会自动使用.

In Spring Cloud Brixton it seems that if Apache HttpClient or OkHttpClient are available (via @ConditionalOnClass) then they are automatically used.

这篇关于Spring Cloud:Feign和Http连接池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆