是HTTP连接池可能吗? [英] Is HTTP connection pooling possible?
问题描述
对于C#web服务接触有限的一组其他服务器,我想创建每个我希望能够联系服务器1 HTTP连接池。
For a C# webservice that contacts a limited set of other servers, I wish to create 1 HTTP connection pool per server that I want to be able to contact.
课程的基本理念:
- 每个池应打开几个连接(可连接3个?),以它的远程Web服务器,并保持这些连接活着
- 系统最大时间到生活应使用回收(断开/重新连接)连接到远程Web服务器,防止远程Web服务器断开连接,我们之前做。
- 的连接不能同时创建,但在3个连接之间的一个小停顿,以便回收也不会同时发生。
- 如果远程Web服务器仍然如果重新连接是不可能因为某些原因,重试应稍微停顿后进行不意外断开,应该注意到,我们应该重新连接。
- 。
- Each pool should open a few connections (3 connections?) to its remote webserver, and keep those connections alive.
- A max-time-to-life should be used to recycle (disconnect/reconnect) the connections to the remote webserver, preventing the remote web server to disconnect before we do.
- The connections should not be created simultaneously but with a little pause between the 3 connections so the recycling also does not happen simultaneously.
- If the remote webserver still does disconnect unexpectedly, it should be noticed and we should reconnect.
- If reconnecting is not possible for some reason, a retry should be done after a little pause.
这样,当我想送一个HttpWebRequest的,我已经准备好使用的连接,不放过建立在,我想此刻的连接时间使用它。
This way, when I want to send a HttpWebRequest, I have ready-to-use connections, sparing the time of setting up the connection at the moment that I want to use it.
目前,我不知道这是连的HttpWebRequest的默认功能。很抱歉,如果我问的很明显。 。谷歌搜索这不仅导致我对Java类似的问题。
At the moment I don't know if this is even a default feature of HttpWebRequest. So sorry if I'm asking for the obvious. Googling for this only led me to similar questions for Java.
问题1:有没有出现在.NET / C#这样的事情
Question 1: is there such a thing present in .NET/c#?
问题2:如果不是,是否有这个目前在互联网上的资源,你知道的。
Question 2: if not, is there a resource on this present on the internet, that you know of?
问题3:如果不是,如何处理建立一个自己?
Question 3: if not, how to approach building one myself?
推荐答案
HttpWebRequest的(基本上意味着.NET所有的HTTP的API)已经利用连接池的默认的
HttpWebRequest (which essentially means all Http APIs in .net) already makes use of connection pooling by default.
看看的的ServicePoint 和的 ServicePointManager 类,如果您需要管理的任何连接池的参数。
Take a look at ServicePoint and ServicePointManager classes if you need to manage any of the parameters of the connection pool.
这篇关于是HTTP连接池可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!