Fra*_*non 3 web-server coldfusion
我们有两个 Coldfusion 服务器,它们在完全相同的输入数据上运行完全相同的代码,它们具有巨大的性能差异。有问题的代码实例化了大量 CFC(Coldfusion Components,类似于 OOP 语言中的对象)。
我通过运行 Process Monitor 比较了两台服务器,然后在两台机器上调用有问题的代码。我学到了两件事。首先,Coldfusion 每次实例化一个对象时都会打开 CFC 文件。两台服务器都这样做,因此它不会成为性能差异的原因。其次,快速服务器直接打开 CFC 文件,而有性能问题的服务器似乎在路径中导航,直到到达所需的 CFC 文件。它对每个文件执行此操作,甚至是它之前加载的文件,并且由于代码实例化了如此多的 CFC,因此它变得非常慢。请参阅下面显示此行为的部分 Promon 跟踪。慢速服务器可能需要 60 多秒才能完成快速服务器在 2 秒内完成的操作。
谁能告诉我是什么导致了这种行为?它是 Coldfusion 设置吗?由于 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
Run Code Online (Sandbox Code Playgroud)
慢速服务器打开 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
Run Code Online (Sandbox Code Playgroud)
谢谢
小智 7
在我看来,您没有在慢速服务器上的 CFAdmin(服务器设置 > 缓存)中检查“组件缓存”。
另一种可能性是您在两个服务器之间设置了不同的 CF 映射(服务器设置 > 映射)和/或自定义标记路径(扩展 > 自定义标记路径)。
不过最有可能是前者。
您还可以设置“请求中的缓存模板”(服务器设置 > 缓存)以防止在给定请求的第一个 CFC 之后查找相同 CFC 的文件,如果它是生产服务器,请选中“受信任的缓存”(服务器设置 > 缓存)也是如此,如果文件已经加载过一次,这将阻止任何文件系统查找。
ColdFusion 还将一次只在内存中维护特定数量的编译文件,由“最大缓存模板数”(服务器设置 > 缓存)设置,您应该尝试将其设置为包含 CFML 文件的总数(和CFC 方法,每个方法都编译为它们自己的类)在您的应用程序中。显然,这取决于 JVM 有足够的 RAM 来处理这个问题。这可能是一种平衡行为。
归档时间: |
|
查看次数: |
892 次 |
最近记录: |