CFHTTP:先请求快,后慢 [英] CFHTTP: first request fast, following slow

查看:14
本文介绍了CFHTTP:先请求快,后慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm having a lot of trouble with CF10's CFHTTP at the moment.

首先,我的测试脚本:

<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 调用,它们所花费的时间被推送到一个数组中;就是这样.

10 CFHTTP calls in a row, the time they take gets pushed to an array; that's all.

我们的 CF9 服务器的结果:

Results of our CF9 server:

我们的 CF10 服务器的结果:

Results of our CF10 server:

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

Results of our CF10 server with 5 sec delay between CFHTTP calls:

我已经在 论坛Shilpi 的博客,原因可能是 Linux 服务器的熵耗尽.我在运行测试脚本时使用 watch --interval=0.1 cat ... 进行了检查,但它从未低于 4k(使用 rngd 已安装).

I already read on the forum and Shilpi's Blog that the reason could be that the Linux server runs out of entropy. I checked that with watch --interval=0.1 cat ... while my test script ran but it never dropped far under 4k (with rngd already installed).

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

Does anybody has another idea what I could try to fix this problem? Using /dev/urandom seems to be an insecure hack to me; so that's not an option (since CF10 server is production machine).

谢谢大家!

推荐答案

在对 Coldfusion 服务器进行 cfhttp 调用时,apache httpclient 库会尝试生成一个安全的随机数.这是一个依赖于熵"的操作.系统.

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.

在 linux 系统(主要是新安装的系统)的情况下,观察到此操作可能非常耗时,因为系统熵"显然很低.因此,cfhttp 调用会很慢.

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 设置中.

Solution: Add "-Djava.security.egd=file:/dev/./urandom" to your jvm-setting.

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

In the Adobe Forums, you find another thread with your problem and the same solution and a following link with further informations about the random number generator: http://forums.adobe.com/thread/1063806

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

There is no need for not using /dev/urandom as it is a secure solution: https://security.stackexchange.com/a/3939

这篇关于CFHTTP:先请求快,后慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆