doupai6875 2015-10-14 13:04
浏览 26

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?

  • 写回答

1条回答 默认 最新

  • duanji1043 2016-02-02 06:43
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 WPF使用Canvas绘制矢量图问题
  • ¥15 用三极管设计一个单管共射放大电路
  • ¥20 fluent无法启动
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决