I have isolated some code within some other guys code which is causing our servers to grind to a halt. This occurs every time an mcrypt function is called.
$iv = ($iv === false) ? mcrypt_create_iv(mcrypt_enc_get_iv_size($this->td), $random_seed) : substr($iv, 0, mcrypt_enc_get_iv_size($this->td));
$iv by default is false. As such every time mcrypt_create_iv(mcrypt_enc_get_iv_size($this->td), $random_seed) is called. We see a build up of sleeping connection states.
Has anyone got any idea as to why. I've done a little probing and can't seem to figure out a solution to this particular line.
Use MCRYPT_DEV_URANDOM instead (see http://www.php.net/manual/en/function.mcrypt-create-iv.php ) and check permissions on /dev/random and /dev/urandom.
See Wikipedia for when dev urandom is better and when dev random: