PHP hash_pbkdf2在AWS实例上花费的数量级更长

We wanted to benchmark the hash_pbkdf2 function in PHP to select an appropriate number of iterations for our application to use.

When I ran my benchmark script on an m4.large AWS instance, it took five orders of magnitude longer to run than it does on my laptop.

This Gist shows the script I am using, and the results I get from an m4.large instance (under load), a t2.micro instance (with full CPU credits and no load) and three different speed Intel i7 laptops.

https://gist.github.com/roberthl/301a3fb0a32baf057806

You can see the 100,000 iterations take <200ms on the i7 laptops, but just a single iteration takes that long on the AWS instances.

I've included the PHP versions, and an OpenSSL benchmark that shows sha256 taking a comparable amount of time on both the AWS instances and an i7 laptop (and a rudimentary benchmark of the PHP hash function also showed this) - suggesting it is specifically related to the PBKDF2 operation.

What causes this to happen, and how can I speed it up?

download20151010
download20151010 只是一个猜测:pbkdf2函数使用普通的PHP-也用于散列,散列使用本机代码。他们可能不想升级它;pbkdf2会花费很多时间在服务器上。
大约 5 年之前 回复

1个回答



请注意,AWS实例使用的是GIST中所有内容的最旧PHP版本。 这不可能很棒。 </ p>

如果可以的话,找一个最近年份的便携式PHP产品并安装和测试它。 </ p>

此外,您可以通过我对各种PBKDF2实施进行基准测试 Github存储库,包括PolarSSL,OpenSSL和基于Crypto ++的版本,所有版本都具有相同的命令行和源代码接口。</ p>
</ div>

展开原文

原文

Note that the AWS instances are using the oldest PHP version of everything in your GIST. That can't be great.

If you can, find a Portable PHP product of recent vintage and install and benchmark it instead.

Additionally, you can benchmark a variety of PBKDF2 implementations from my Github repository, including PolarSSL, OpenSSL, and Crypto++ based versions, all with identical interfaces for the command line and source code.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐