Bottom Line: I'm trying to figure out if ColdFusion can use a persistent http connection outside of a single request through the CFHTTP tag. Some of these posts are "what I found / tried."
My system: CF10 IIS7.5 Windows 7
I am currently connecting to ElasticSearch through the HTTP Rest interface, which will have the volume of cfhttp calls. In this case, ColdFusion is the client, and ElasticSearch is the server. As recommended, I passed the keep-alive header along with the cfhttp request, but found that CFHTTP seemed to always add a closure immediately after it appeared in this header:
<cfhttp url="loc.mysite.com?endpoint" method="POST" result="ret"> <cfhttpparam type="HEADER" name="Keep-Alive" value="300"> <cfhttpparam type="HEADER" name="Connection" value="keep-alive"> <cfhttpparam type="xml" value="#body#" /> </cfhttp> connection: keep-alive,closed
Firstly, I canβt figure out how to prevent the closure.
Secondly, I cannot understand whether ColdFusion will reuse the connection, even if it is sent without closing during the same request or outside of this request. Obviously, this is due to the way Java interacts with the OS at this point. Initially, I thought it would be handled by ColdFusion magic, but I'm starting to think that it does not use any fantastic Java pool magic.
Thirdly, I cannot find documentation on combining http connections in ColdFusion. This DB pooling is just fine, but the http pool is probably a relatively new requirement.
Fourth, I found that CFX_http5 still works in ColdFusion 10 with Tomcat (what are the odds). Although this is good for multi-threaded queries, little mention is made of how keep-alive is used. Without buying it, I cannot check it inside the loop. It does not add a closing header. He goes to standby, as expected.
Sixth (heavily edited since its inception) Sixth, Windows has by default the number of temporary or βephemeralβ ports that it can use to create new outbound TCP connections. By default, as soon as the connection is open, Windows will support it for two minutes (although it just left and took a place at this point). This is a TCP configuration, so the HTTP headers do not play here. The number of available ports by default is less than 5000 ports 1024 = 3076. This means that all ColdFusion instances on a box can make up to 3076 HTTP requests in any two-minute window without interrupting waiting on an available connection port. If too many requests are flooded (I have no idea at what point), you will receive a "connection closed" error message. It reminds me of garbage collection at a primitive level. So, down to the level in the registry (see Message) below, and you are avoiding these chokes, but you are still experiencing connection / stall delays and this solution will not scale.
Refresh . CFX_HTTP5 supports supported and persistent connections, as expected, within a single ColdFusion request. My 150K test request to my ElasticSearch endpoint ran after 15 minutes. He worked with CFX_HTTP5 after 4 minutes. In addition, I managed to switch the registry to the default number of ports. The next step is to find out if HTTPComponents will work. It almost works for me.
Update 2:. Created a custom HTTP call using the HTTP components suggested below. I used the base connection pool manager with the default settings. I have not tried to configure it yet. The process completed in 5 minutes, which is slightly slower than cfx_http5, but still much faster than cfhttp. In addition, I have not tested several ColdFusion queries to really test the connection pool.
Update 3: I confirmed that HTTPComponents is indeed setting up the correct connection pool. However, this creates responsibility for the proper management of these connections and the pool itself, to ensure that it is a good manager of system resources. I was able to run several million HTTP requests from several different simultaneous requests, only by opening a small part of HTTP connections. From the logs, I was able to find out how many connections were used, simple or deployed. This is really not a lot of code, the people behind the project have excellent documentation.
HTTPComponents Connection Pool: Single request, unlimited CFHTTP to same connection = single open TCP connection N-requests = <N open TCP connections. CFHTTP N-CFHTTP calls + N-CFHTTP calls in previous 60 seconds = open TCP connections
Link: I found that Java has this available, which shows that it is in the realm of possibilities, but who knows how Adobe implemented CFHTTP Permanent HTTP client connection in java
The custom tag CFX_http5 uses C ++ for custom HTTP connections, so it is possible that it understands pooling. http://www.cftagstore.com/tags/cfxhttp5.cfm
Related question: Maintain outbound TCP connection pool in ColdFusion
About Windows Max Connections / Ephemeral Ports http://kb.globalscape.com/KnowledgebaseArticle10438.aspx