symfonycachingshared-memory

symfony cache dir /dev/shm in production?


You can define a custom cache dir in Kernel.php and use the shared memory via /dev/shm

public function getCacheDir(): string
{
  return '/dev/shm/sf-cache/'.$this->environment;
}

This is somewhat recommended for developing on virtual machines on non-linux systems like vagrant / docker, as it significantly speeds up things there.

Could you also use that in production as a faster filesystem alternative?
If not, why? What are potential downsides?


Solution

  • Using standard SSD nowadays makes (almost) no difference between using disk

    On my app, clearing (and warming up) cache on shm is 0.1s faster.