Web-Server

兩個 Web 伺服器之間的巨大性能差異,使用程序監視器看到的奇怪行為

  • November 26, 2012

我們有兩個具有巨大性能差異的 Coldfusion 伺服器,它們在完全相同的輸入數據上執行完全相同的程式碼。有問題的程式碼實例化了大量的 CFC(Coldfusion 組件,類似於 OOP 語言中的對象)。

我通過執行 Process Monitor 然後在兩台機器上呼叫有問題的程式碼來比較兩台伺服器。我學到了兩件事。首先,Coldfusion 每次實例化對象時都會打開 CFC 文件。兩台伺服器都這樣做,因此它不能成為性能差異的原因。其次,快速伺服器直接打開 CFC 文件,而有性能問題的伺服器似乎在路徑中導航,直到到達所需的 CFC 文件。它對每個文件都執行此操作,甚至是之前載入的文件,並且由於程式碼實例化瞭如此多的 CFC,它變得非常慢。請參閱下面顯示此行為的部分 Promon 跟踪。慢速伺服器在 2 秒內完成快速伺服器的工作可能需要 60 多秒。

誰能告訴我是什麼導致了這種行為?是冷融合設置嗎?由於 Coldfusion 在 Java 之上執行,它是 Java 設置嗎?它是作業系統選項嗎?快速伺服器執行的是 Windows XP,我認為慢速伺服器是 Windows Server 2003。

額外問題:Coldfusion 似乎沒有對任何 CFC 或 CFM 文件執行任何 READ FILE 操作。怎麼會這樣?

快速伺服器打開 CFC 文件的範例:

11:25:14.5588975    jrun.exe    QueryOpen                   C:\CF\wwwroot\APP\com\HtmlUtils.cfc
11:25:14.5592758    jrun.exe    CreateFile                  C:\CF\wwwroot\APP\com\HtmlUtils.cfc
11:25:14.5595024    jrun.exe    QueryBasicInformationFile   C:\CF\wwwroot\APP\com\HtmlUtils.cfc
11:25:14.5595940    jrun.exe    CloseFile                   C:\CF\wwwroot\APP\com\HtmlUtils.cfc
11:25:14.5599628    jrun.exe    CreateFile                  C:\CF\wwwroot\APP\com\HtmlUtils.cfc
11:25:14.5601600    jrun.exe    QueryBasicInformationFile   C:\CF\wwwroot\APP\com\HtmlUtils.cfc
11:25:14.5602463    jrun.exe    CloseFile                   C:\CF\wwwroot\APP\com\HtmlUtils.cfc

慢速伺服器打開 CFC 文件的等效範例:

11:15:08.1249230    jrun.exe    CreateFile                  D:\
11:15:08.1250100    jrun.exe    QueryDirectory              D:\org
11:15:08.1252852    jrun.exe    CloseFile                   D:\
11:15:08.1259670    jrun.exe    CreateFile                  D:\org
11:15:08.1260319    jrun.exe    QueryDirectory              D:\org\cli
11:15:08.1260769    jrun.exe    CloseFile                   D:\org
11:15:08.1269451    jrun.exe    CreateFile                  D:\org\cli
11:15:08.1270613    jrun.exe    QueryDirectory              D:\org\cli\cpn
11:15:08.1271140    jrun.exe    CloseFile                   D:\org\cli
11:15:08.1279312    jrun.exe    CreateFile                  D:\org\cli\cpn
11:15:08.1280086    jrun.exe    QueryDirectory              D:\org\cli\cpn\APP
11:15:08.1280789    jrun.exe    CloseFile                   D:\org\cli\cpn
11:15:08.1291034    jrun.exe    CreateFile                  D:\org\cli\cpn\APP
11:15:08.1291709    jrun.exe    QueryDirectory              D:\org\cli\cpn\APP\com
11:15:08.1292224    jrun.exe    CloseFile                   D:\org\cli\cpn\APP
11:15:08.1300568    jrun.exe    CreateFile                  D:\org\cli\cpn\APP\com
11:15:08.1301321    jrun.exe    QueryDirectory              D:\org\cli\cpn\APP\com\HtmlUtils.cfc
11:15:08.1301843    jrun.exe    CloseFile                   D:\org\cli\cpn\APP\com
11:15:08.1312049    jrun.exe    CreateFile                  D:\org\cli\cpn\APP\com\HtmlUtils.cfc
11:15:08.1314409    jrun.exe    QueryBasicInformationFile   D:\org\cli\cpn\APP\com\HtmlUtils.cfc
11:15:08.1314633    jrun.exe    CloseFile                   D:\org\cli\cpn\APP\com\HtmlUtils.cfc
11:15:08.1315881    jrun.exe    CreateFile                  D:\
11:15:08.1316379    jrun.exe    QueryDirectory              D:\org
11:15:08.1316926    jrun.exe    CloseFile                   D:\
11:15:08.1330951    jrun.exe    CreateFile                  D:\org
11:15:08.1338656    jrun.exe    QueryDirectory              D:\org\cli
11:15:08.1339118    jrun.exe    CloseFile                   D:\org
11:15:08.1526468    jrun.exe    CreateFile                  D:\org\cli
11:15:08.1527295    jrun.exe    QueryDirectory              D:\org\cli\cpn
11:15:08.1527989    jrun.exe    CloseFile                   D:\org\cli
11:15:08.1531977    jrun.exe    CreateFile                  D:\org\cli\cpn
11:15:08.1532589    jrun.exe    QueryDirectory              D:\org\cli\cpn\APP
11:15:08.1533575    jrun.exe    CloseFile                   D:\org\cli\cpn
11:15:08.1538457    jrun.exe    CreateFile                  D:\org\cli\cpn\APP
11:15:08.1539083    jrun.exe    QueryDirectory              D:\org\cli\cpn\APP\com
11:15:08.1539553    jrun.exe    CloseFile                   D:\org\cli\cpn\APP
11:15:08.1544126    jrun.exe    CreateFile                  D:\org\cli\cpn\APP\com
11:15:08.1544980    jrun.exe    QueryDirectory              D:\org\cli\cpn\APP\com\HtmlUtils.cfc
11:15:08.1545482    jrun.exe    CloseFile                   D:\org\cli\cpn\APP\com
11:15:08.1551034    jrun.exe    CreateFile                  D:\org\cli\cpn\APP\com\HtmlUtils.cfc
11:15:08.1552878    jrun.exe    QueryBasicInformationFile   D:\org\cli\cpn\APP\com\HtmlUtils.cfc
11:15:08.1553044    jrun.exe    CloseFile                   D:\org\cli\cpn\APP\com\HtmlUtils.cfc

謝謝

按照 Adam Cameron 的回答,我建議在兩台機器上比較 C:\ColdFusion8\lib\neo*.xml 並解決差異,特別是 neo-runtime.xml 和 neo-debug.xml - 這些是儲存 ColdFusion 的配置。在此處發布任何有趣的差異。

如果您沒有 diff 工具,請使用BeyondCompare的試用版,因為它會處理整個目錄並很好地支持 XML。

在我看來,您沒有在慢速伺服器上的 CFAdmin(伺服器設置 > 記憶體)中檢查“組件記憶體”。

另一種可能性是您在兩台伺服器之間設置了不同的 CF 映射(伺服器設置 > 映射)和/或自定義標記路徑(擴展 > 自定義標記路徑)。

不過最有可能是前者。

您還可以設置“請求中的記憶體模板”(伺服器設置 > 記憶體)以防止在給定請求的第一個 CFC 之後查找同一 CFC 的文件,如果它是生產伺服器,請檢查“受信任的記憶體”(伺服器設置>記憶體),如果文件已經載入過一次,這將阻止任何文件系統查找。

ColdFusion 也將一次只在記憶體中維護特定數量的編譯文件,由“記憶體模板的最大數量”(伺服器設置 > 記憶體)設置,您應該嘗試將其設置為包含 CFML 文件的總數(和CFC 方法,每個方法都編譯成自己的類)在您的應用程序中。顯然,這是基於 JVM 有足夠的 RAM 來處理這個問題。這可能是一種平衡行為。

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