mercredi 14 octobre 2015

PHP hash_pbkdf2 takes orders of magnitude longer on AWS instances

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.

http://ift.tt/1X3bI9J

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?




Aucun commentaire:

Enregistrer un commentaire