Tomcat

Coldfusion 10 保持活動請求 = 0?

  • January 7, 2013

針對 .jsp 頁面 (Tomcat7) 和 .cfm 頁面 (Coldfusion10 Enterprise) 執行“ab”。ab 正確記錄了 .jsp 頁面的 keep-alive 結果,但沒有正確記錄 .cfm 頁面的結果。CF似乎不尊重保命?也許是一個設置?我用Google搜尋並查看了 CF 管理員無濟於事。

注意: .jsp 在單獨的 tomcat7 實例下執行。CF10 作為獨立伺服器安裝,帶有自己的下劃線 tomcat 伺服器。此時不關心“每秒請求數”,希望有人能幫助我理解為什麼 CF 的“Keep-Alive 請求”為 0?刷新時沒有計算內容長度?

(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

索引.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>

索引.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>

原來 CF 預設不計算 Content-Length 。修復是計算輸出長度並將其添加到 Application.cfc / onRequestEnd 下的 Content-Length 標頭中。

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

在覆蓋它之前先測試這個標題是否存在可能是明智的,但對於我的測試,它工作得很好。恕我直言,這應該是 CF 中的一個自動魔法功能,我想不出你不想計算 Content-Length 並將其添加為標題的原因。

一個很好的閱讀: http ://docstore.mik.ua/orelly/java-ent/servlet/ch05_03.htm

一些功勞: http ://forums.adobe.com/message/4411537

引用自:https://serverfault.com/questions/463490