HHVM Tuning

  • Disabling The Typechecker:

HHVM automatically runs the typechecker – this is useful in development, but assuming you have it running in your development workflow and in your CI system, there is not much additional benefit to running it in production, and the increased memory usage can be costly in production. To disable it, add the following to /etc/hhvm/server.ini:

Reference:
https://hub.docker.com/r/hhvm/hhvm-proxygen/

  • Switch to UNIX socket inside of port for fastcgi mode:

HHVM is considered for environments under heavy load so the first configuration change you can do is to make HHVM listen to a socket instead of a TCP port. Thus, the communication between Nginx and HHVM will require less CPU and memory.

Add this to: /etc/hhvm/server.ini

I also common out the port line to increase a bit of security.

Then change the Nginx config to hhvm as well:
/etc/nginx/hhvm.conf

  • Tweaking Memory:

By default the memory_limit is equal to 17179869184 bytes, which is 16 GB.
Such a high memory resource limit will certainly kill a server with a few GB of RAM, making it unresponsive.
I decrease this value to 500 MB for a 1 GB memory Server:

Add this to: /etc/hhvm/php.ini

Restart to apply the changes:

Reference:
https://www.digitalocean.com/community/tutorials/how-to-install-hhvm-with-nginx-on-ubuntu-14-04

  • A much more pushed example for a bigger server:

Reference:
https://github.com/facebook/hhvm/issues/7754

Leave a Reply

Your email address will not be published. Required fields are marked *