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 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机