openvz tmpfs and dcachesize

When using tmpfs inside OpenVZ containers, make sure to monitor and increase dcachesize (directory and inode entries) appropriately.

tmpfs mounts can be used to speed up applications doing lots of read/writes to temporary diskspace such a php sessions and mysql tmp directory.

Mount using "/etc/fstab":

tmpfs   /dev/shm        tmpfs   noexec,nosuid,nodev   0 0
tmpfs   /var/lib/php/session    tmpfs   mode=770,gid=48,size=500M,noexec,nosuid,nodev,noatime     0 0

Note: default folder permission of "/var/lib/php/session" is 770 and set to the apache Group ID.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

session folders in tmpfs mount

If placing folders inside of the tmpfs mount, make sure to add to "/etc/rc.local" file, so the folder gets recreated on server reboot.

In "/etc/rc.local":

# Magento sessions
[ ! -d "/var/lib/php/session/magento/" ] && sudo -u apache mkdir /var/lib/php/session/magento/

Comment