我们有两台Coldfusion服务器,在完全相同的input数据上运行完全相同的代码,性能差异巨大。 问题中的代码实例化大量的CFC(Coldfusion组件,与OOP语言中的对象类似)。
我通过运行Process Monitor来比较两台服务器,然后在两台机器上调用有问题的代码。 我学到了两件事 首先,ColdFusion在每次实例化对象时打开CFC文件。 两台服务器都这样做,所以不能成为性能差异的原因。 其次,快速服务器直接打开CFC文件,而具有性能问题的服务器似乎是通过path导航,直到达到所需的CFC文件。 它为每个文件,甚至是之前加载的文件都这样做,并且因为代码实例化了如此多的CFC,所以它变得非常慢。 看下面显示这种行为的部分Promon迹线。 慢速服务器可能需要60秒才能完成2秒钟内完成的任务。
谁能告诉我是什么原因导致了这种行为? 这是一个Coldfusion的设置? 由于Coldfusion在Java之上运行,它是Java设置吗? 这是一个操作系统选项? 快速服务器运行Windows XP,我认为慢速服务器是Windows Server 2003。
奖金问题:Coldfusion似乎不对任何CFC或CFM文件执行任何“读取”文件操作。 怎么会这样?
快速的服务器打开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的回答,我build议在两台机器上比较C:\ ColdFusion8 \ lib \ neo * .xml,并通过差异来处理,特别是neo-runtime.xml和neo-debug.xml – 这些都是存储ColdFusion的configuration。 在此发布任何有趣的差异。
如果您没有diff工具,请使用BeyondCompare的试用版,因为它可以完成整个目录并支持XML。
这听起来像你没有在慢速服务器上的CFAdmin(服务器设置>caching)中检查“组件caching”。
另一种可能是您在两台服务器之间设置了不同的CF映射(服务器设置>映射)和/或自定义标记path(扩展>自定义标记path)。
这很可能是前者。
您也可以设置“请求caching模板”(服务器设置>caching),以防止在给定请求的第一个文件后查找同一CFC,如果是生产服务器,请选中“可信caching”设置>caching),这将阻止任何文件系统查找,如果该文件已被加载一次。
ColdFusion每次只能在内存中维护特定数量的编译文件,由“caching模板的最大数量”(Server Settings> Caching)设置,您应该尝试将其设置为包含CFML文件的总数CFC方法,每个方法都可以编译到自己的类中)。 显然,这是基于JVM有足够的内存来处理这个问题。 这可能是一个平衡的行为。
尝试检查:
cfdump
。