Thursday, 16 January 2020

PHP shared memory: shm vs shmop vs SyncSharedMemory

In PHP, there are different extensions available for shared memory:

shm, part of the "Semaphore" extension in the docs that uses system V IPC functions:

https://www.php.net/manual/en/intro.sem.php

And shmop, a PHP-native extension:

https://www.php.net/manual/en/intro.shmop.php

The docs are very slim, so far I have found just these differences:

  • SysV-Shared memory allows usage from non-PHP programs
  • SysV-Shared memory is not available on Windows

Since we for sure will never use Windows as a server and also have a couple of C-based programs which may benefit from shared memory access, I would prefer Sys-V based shared memory.

Edit: I just discovered a third one: The SyncSharedMemory class in the "sync" extension.

Are there any performance differences between these three extensions and/or are there any other notable differences between them?



from PHP shared memory: shm vs shmop vs SyncSharedMemory

No comments:

Post a Comment