Skip to main content
Participating Frequently
September 10, 2012
Answered

throttled CFHTTP

  • September 10, 2012
  • 3 replies
  • 7775 views

i recently upgraded from cf9 to cf10. running single instance on a brand new ubuntu server 12.04 with Apache. same settings as my other ubuntu servers as far as i can tell. Suddenly, all my cfhttp tags are being throttled with about 5 second breaks being pushed into each one. Each additional request made pushes the time taken up 5 seconds. i've compared every setting i could think of to the cf9 servers but nothing worked.

Here's from the http.log:

HTTP request completed {Status Code=200 ,Time taken=28525 ms}
Sep 10, 2012  5:13 PM  Information  ajp-bio-8012-exec-18 
HTTP request completed {Status Code=200 ,Time taken=22752 ms}
Sep 10, 2012  5:13 PM  Information  ajp-bio-8012-exec-23 
HTTP request completed {Status Code=200 ,Time taken=17549 ms}
Sep 10, 2012  5:13 PM  Information  ajp-bio-8012-exec-17 
HTTP request completed {Status Code=200 ,Time taken=12320 ms}
Sep 10, 2012  5:13 PM  Information  ajp-bio-8012-exec-22 
HTTP request completed {Status Code=200 ,Time taken=7137 ms}
Sep 10, 2012  5:13 PM  Information  ajp-bio-8012-exec-25 
HTTP request completed {Status Code=200 ,Time taken=4302 ms}
Sep 10, 2012  5:13 PM  Information  ajp-bio-8012-exec-23 
Starting HTTP request {URL='http://www.google.com', method='GET'}
Sep 10, 2012  5:13 PM  Information  ajp-bio-8012-exec-17 
Starting HTTP request {URL='http://www.google.com', method='GET'}
Sep 10, 2012  5:13 PM  Information  ajp-bio-8012-exec-22 
Starting HTTP request {URL='http://www.google.com', method='GET'}
Sep 10, 2012  5:13 PM  Information  ajp-bio-8012-exec-19 
Starting HTTP request {URL='http://www.google.com', method='GET'}

Any help would be greatly appreciated.

Thanks!

This topic has been closed for replies.
Correct answer rupesh_kumar

psu_josh wrote:

I can also report that 10,0,5,283319 doesn't solve this issue for me.

Not that this would matter. 10.0.5 is a Windows security update. As you say, the bottle-neck is likely a Linux issue. So what is it on Linux systems that is queueing up the threads?


We investigated this and found out that this does happen on some Linux machines but not all. The reason it happens is because Apache HttpClient library creates a SecureRandom number for every http call which can be slow on new Unix boxes as there are not enough entropy generated on those machines.

There are few possible ways to solve this and I would recommend either of these two.

  1. 1. Set this system property to your JVM – if you are using standalone CF installation, you would set it in jvm.config.

“-Djava.security.egd=file:/dev/./urandom”

  1. 2. In $JAVA_HOME/jre/lib/security/java.security file, change the value of securerandom.source to file:/dev/./urandom

You can also refer to this excellent post by Shilpi from the ColdFusion team which talks about this issue

http://www.shilpikhariwal.com/2012/04/random-number-generation-in-unix.html

3 replies

Inspiring
November 19, 2012

It's not much help, but I ran a few tests and I don't see what you're seeing on my CF10 install: all CFHTTP requests are being fired immediately, and the length of time they take to complete is roughly the same per request. IE: I'm not seeing anything I would not expect to see if the thing was working properly.

My CF10 install is a bog-standard one, patched to 10.0.4.  CF10 Developer, running on Windows 7 Home 64-bit.

--

Adam

Participating Frequently
November 19, 2012

So this to me helps narrow down the problem. You are saying it runs fine for you on windows. So far the only people who have reported issues are on Linux.

Participating Frequently
November 19, 2012

I can also report that 10,0,5,283319 doesn't solve this issue for me.

BKBK
Community Expert
Community Expert
November 16, 2012

I have added the following note to the bug report. This may sound crazy, but I've seen weirder things in ColdFusion. It just might be that what you observe is expected behaviour, assuming single-threaded processing.

Say, you have 10 cfhttp tags in a loop. When the loop starts, ColdFusion first processes a number of cfhttp start-tags, perhaps up to all 10 of them, possibly without strictly respecting order. Since the processing is single-threaded, ColdFusion executes the tag bodies in series, one after the other. This would explain why the successive execution times are cumulative.

See Ben Nadel's blog on using cfthread with cfhttp. There he solves the problem by using multiple, asynchronous threads, like this:

<cfloop index="intGet" from="1" to="10">

<!--- Start a new thread for this CFHttp call. --->

<cfthread action="run" name="objGet#intGet#">

<cfhttp method="GET" url="some_url" result="THREAD.Get#intGet#" />

</cfthread>

</cfloop>

<!---

Now, we have to wait for all of concurrent threads to be joined before we can use the CFHttp results.

--->

<cfloop index="intGet" from="1" to="10">

<cfthread action="join" name="objGet#intGet#" />

</cfloop>

shudini1Author
Participating Frequently
November 16, 2012

the only thing is that the exact same code runs perfectly fine in a single-threaded process on CF9. it was only after upgrading that we noticed this. I'd rather not have to go into all of the code and modify it just because something changed on the CF side.

Additionally, while in the log example I posted I was using a single threaded, single request to initiate multiple CFHTTP calls, this problem actually manifested on our site when multiple users began accessing some of our pages that make use of CFHTTP.

However, just so no one can accuse me of not willing to try to find a workaround, I took Ben's code from this page: http://www.bennadel.com/blog/749-Learning-ColdFusion-8-CFThread-Part-II-Parallel-Threads.htm and tested on a CF9 and CF10 configuration.

.

Here are the results from the servers:

CF9: We Got 1000 Results in 0.72 seconds using CFHttp and CFThread

CF10: We Got 1000 Results in 45.02 seconds using CFHttp and CFThread

So it doesn't really seem like parallel threads would help out here.

BKBK
Community Expert
Community Expert
November 16, 2012

45 to 0.7 is indeed a big ratio. That does not necessarily rule out the effect of single versus parallel threads. My guess is that some other factor in CF 10 is forcing single-threading.

To start with, perhaps these settings in the Administrator:

"Maximum number of simultaneous Template requests

The number of CFML page requests that can be processed concurrently. Use this setting to increase overall system performance for heavy load applications. Requests beyond the specified limit are queued.

Maximum number of threads available for CFTHREAD

The maximum number of threads created by CFTHREAD that will be run concurrently. Threads created by CFTHREAD in excess of this are queued."

Participating Frequently
November 8, 2012

I am also seeing this. Tcpdump shows that it isn't the web server slowing things down. It does appear to be in the cfhttp tag. Did you find an answer to this?

shudini1Author
Participating Frequently
November 8, 2012

unfortunately I never figured this out. In the meantime I downgraded to CF 9 until I either figure it out or there's an update that fixes the problem. Maybe it should be submitted as a bug request...

12Robots
Participating Frequently
November 8, 2012

Maybe?