performance - CFHTTP:第一个请求快,后续慢

标签 performance coldfusion coldfusion-10 entropy cfhttp

目前我在使用 CF10 的 CFHTTP 时遇到了很多麻烦。

首先,我的测试脚本:

<CFSET results = arraynew(1) />
<CFLOOP from="1" to="10" index="idx">
    <CFSET timer_start = getTickCount() />
    <CFHTTP url="https://www.google.de" method="get" result="test" />
    <CFSET arrayappend(results, (getTickCount()-timer_start)/1000 & " s") />
</CFLOOP>
<CFDUMP var="#results#" />

连续 10 个 CFHTTP 调用,它们所花费的时间被推送到一个数组中;仅此而已。

我们的 CF9 服务器的结果:

CF9 CFHTTP TEST RESULTS

我们的 CF10 服务器的结果:

CF10 CFHTTP TEST RESULTS

CFHTTP 调用之间有 5 秒延迟的 CF10 服务器的结果:

CF10 CFHTTP TEST RESULTS WITH DELAY BETWEEN CALLS

我已经读过 forumShilpi's Blog原因可能是 Linux 服务器耗尽了熵。当我的测试脚本运行时,我用 watch --interval=0.1 cat ... 检查了这一点,但它从未下降到远低于 4k(已安装 rngd)。

有人知道我可以尝试解决这个问题吗? 对我来说,使用/dev/urandom 似乎是一种不安全的黑客行为;所以这不是一个选项(因为 CF10 服务器是生产机器)。

谢谢大家!

最佳答案

While making a cfhttp call to a coldfusion server the apache httpclient library tries to generate a secure random number. It is an operation which depends on the "entropy" of the system.

In case of linux systems (mainly the ones which are freshly installed) it is observed that this operation can be quite time consuming because the system "entropy" is apparently quite low. Hence, as a consequence cfhttp calls will be slow.

来源:http://blogs.coldfusion.com/post.cfm/optimizing-cfhttp-calls-on-linux-systems

解决方案:将 “-Djava.security.egd=file:/dev/./urandom” 添加到您的 jvm 设置中。

在 Adob​​e 论坛中,您可以找到另一个与您的问题相关的帖子和​​相同的解决方案,以及以下链接,其中包含有关随机数生成器的更多信息: http://forums.adobe.com/thread/1063806

没有必要不使用/dev/urandom,因为它是一个安全的解决方案:https://security.stackexchange.com/a/3939

关于performance - CFHTTP:第一个请求快,后续慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19183903/

相关文章:

java - 为什么需要等效方法重载?

java - 我怎样才能使这段代码更有效地找到一对总和?

Java:如何获取上传和下载速度

coldfusion - 表单变量和双引号

session - 冷聚变 10 : jessionid not working when passed in url

entity-framework - 创建 1000 个 Entity Framework 对象时,何时应该调用 SaveChanges()? (就像导入期间一样)

jQuery - 我需要对变量进行 URL 编码吗?

javascript - 无法正确读取url

coldfusion - 在 Application.cfc 中设置 Session 变量

coldfusion - ColdFusion-将查询转换为CFC setter