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 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘