0

Ran 'ab' against a .jsp page (Tomcat7) and .cfm page (Coldfusion10 Enterprise). ab correctly records keep-alive results for the .jsp page but not for the .cfm page. It appears keep-alives aren't being honored by CF? Maybe a setting? I've googled and looked within the CF administrator to no avail.

Note: The .jsp is running under a separate tomcat7 instance. CF10 is installed as a standalone server with it's own underlining tomcat server. Not concerned about "Requests per second" at this point, hoping someone can help me understand why "Keep-Alive requests" is 0 here for CF? Content-Length not being calculated upon flush?

(index.jsp)
# ab -kn 1000 -c 10 http://127.0.0.1:8084/

Concurrency Level:      10
Time taken for tests:   0.094 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
**Keep-Alive requests:    995**
Total transferred:      460975 bytes
HTML transferred:       212000 bytes
Requests per second:    10676.46 [#/sec] (mean)
Time per request:       0.937 [ms] (mean)
Time per request:       0.094 [ms] (mean, across all concurrent requests)
Transfer rate:          4806.23 [Kbytes/sec] received

(index.cfm)
# ab -kn 1000 -c 10 http://127.0.0.1:8501/

Concurrency Level:      10
Time taken for tests:   0.395 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
**Keep-Alive requests:    0**
Total transferred:      148148 bytes
HTML transferred:       7007 bytes
Requests per second:    2529.33 [#/sec] (mean)
Time per request:       3.954 [ms] (mean)
Time per request:       0.395 [ms] (mean, across all concurrent requests)
Transfer rate:          365.93 [Kbytes/sec] received

index.cfm

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Test</title>
    </head>
    <body>
        <h1><cfscript> WriteOutput("Hello CF."); </cfscript></h1>
        <!---
        <h1><cfoutput>Hello CF.</cfoutput></h1>
        --->
    </body>
</html>

index.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Test</title>
    </head>
    <body>
        <h1><% out.print("Hello JSP."); %></h1>
    </body>
</html>

1 Answer 1

0

Turns out CF doesn't calculate Content-Length by default. The fix is calculating the output length and adding that to a Content-Length header under Application.cfc / onRequestEnd.

# Application.cfc
# onRequestEnd
<cfheader name="Content-Length" value="#len(getPageContext().getOut().getString())#" />

It's probably wise to test if this header exists first before overwriting it, but for my tests, it worked just fine. IMHO, this should be a auto-magic feature in CF, I cannot think of a reason why you would not want to have Content-Length calculated and added as a header.

A good read: http://docstore.mik.ua/orelly/java-ent/servlet/ch05_03.htm

Some credit to: http://forums.adobe.com/message/4411537

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .