Skip to main content
Known Participant
February 27, 2014
Question

Optimise CFHTTP Requests/Requests Being Throttled?

  • February 27, 2014
  • 1 reply
  • 2431 views

I currently have an application that trades virtual items and is making at least 40 CFHTTP requests per second to the host's server.

The issue I'm encountering is that it's taking anywhere from 400ms+ for my CFHTTP call to return a response which means my application is missing out on 99% of the deals it finds, as there are lots of other competiting applications out there that are getting a faster response.

I've struggled to find a cause and/or a solution to this situation so I wrote a script in both CF and C# that makes 10 http requests timing each one which resulted in the following response times:

In CF using the following browsers:

IE9: 384, 444, 302, 570, 535, 317, 510, 349, 357, 467 - Average 423.5ms

Firefox 27.0.1: 354, 587, 291, 480, 437, 304, 537, 322, 286, 652 - Average 425ms

Chrome: 300, 328, 328, 639, 285, 259, 348, 291, 299, 414 - Average 349.7ms

In C# Console Application:

597, 43, 96, 52, 44, 305, 67, 91, 54, 270 - Average 161.9ms

As you can see there is a big performance difference when making an HTTPWebRequest in a C# Console Application which is making me think that perhaps the CFHTTP requests are being throttled? Or could it maybe be something to do with the browsers?

Any help would be greatly appreciated! 

    This topic has been closed for replies.

    1 reply

    BKBK
    Community Expert
    Community Expert
    February 27, 2014

    You might be worrying for nothing. There are apparently 2 different processes at work here:

    1) CFHTTP is itself a browser! It interacts with the host server;

    2) IE, Firefox and Chrome each interacts with ColdFusion, via the web server, to get the result of the CFHTTP action.

    Your priority is of course for process 1 to be as fast as possible. It is indeed possible that process 1 is super fast, and that process 2 is causing most of the delay that you observe.

    To verify this, go to the Debugging page of the ColdFusion Administrator and check the options Enable Request Debugging Output and Report Execution Times. Then examine the execution times of the page containing the CFHTTP code.

    In use-cases where reaction speed is critical, one technology comes to mind, push technology. You could redesign your application to use websockets. It would then be possible to get the response from the host server as soon as ColdFusion receives it.

    cpb071Author
    Known Participant
    February 28, 2014

    Thanks for your reply.

    Below is a screen dump of the test page I set up which makes 10 requests to a test function. The test function makes a standard CFHTTP call. Each request is timed and the time output on the page.

    From what's there it gives no insight to me of what is actually happening or causing the requests to take so long to complete.

    I've had a look around online the last few hours for web socket example but can find nothing other than creating a chat room! Do you have a link to any material or pseudo code that would allow me to create a test page that used web sockets so I could make a comparison between the request times?

    BKBK
    Community Expert
    Community Expert
    February 28, 2014

    I thought your application involved just CFM pages that implement CFHTTP. Hence my suggestion to enable Debugging Output in the Administrator.

    From the look of it, your application involves invoking CFCs. This calls for a change of plan. You should de-activate Debugging Output. It is a very blunt instrument in the circumstances.

    The cftimer tag or getTickCount function are more appropriate. I guess you are using them already.

    The question remains how to crank up the speed in this new setting. Invoking a function in a CFC to interact with a remote server can be costly in CPU terms. I'll have a think.