HHVM session files


As HHVM is configured by default using the standard ubuntu install, it stores session files - lots of them - in /tmp. I looked in there the other day and there were > 450k files.

The way that debian/ubuntu is set up for cleaning old php session files is to use a cron job that gets rid of the old ones every 30 minutes. But that script expects the session files to live in /var/lib/php5/sessions, not /tmp.

As configured by default, HHVM does not clean up its old sessions and does not get its old sessions cleaned up by the ubuntu script.

A few changes to the HHVM configs will fix this. Here’s how I did it:

Add the following lines to /etc/hhvm/php.ini

session.save_handler = files
session.save_path = /var/lib/php5/sessions
session.gc_probability = 0
session.gc_maxlifetime = 1440

HHVM is also saving some big perf***.map files in /tmp. I could not find any documentation on what those are supposed to be for. Here is some background reading:

I put the following lines into /etc/hhvm/server.ini:

hhvm.keep_perf_pid_map = 0
hhvm.perf_pid_map = 0
hhvm.perf_data_map = 0

Right before I switched over to the new config, I deleted all the session files in /tmp older than 24 minutes (default session length time):

sudo find /tmp -name "sess_*" -cmin +24 -delete

Then I restarted HHVM and then quickly moved all the rest of the session files to the right spot:

sudo service hhvm restart ; sudo mv /tmp/sess_* /var/lib/php5/sessions/

Been running the above config for 24 hours now and it seems good. No more perf***map files and the number of session files in /var/lib/php5/sessions is back in the reasonable realm and not growing exponentially.

Hhvm php.ini misconfiguration, broken sessions

Hi @pjv

Thanks for this useful information. It sure will help the community in case of this issue .

We appreciate you sharing this issue and the workaround. I am closing this support topic for now. Feel free to share suggestions like these in future.