File locking or flock performance issues Print

  • 0

When a plugin uses the PHP function “flock”, it sends a request to the file system to “lock” a specific file and restricts other processes from changing that specific file. This causes a wait time while the plugin completes the operation.

When there are multiple file locks, the amount of latency begins to increase.

Our file system uses a multi-threading mechanism in order to deliver efficient input/output processing. Using the flock function is not compatible with many file systems and can result in site errors with the file system and possible downtime.

As a result, modern plugins have started to move away from using flock. The Wordfence plugin uses flock for their Advanced Firewall Feature, however they have the option to switch to MySQLi Storage Engine.

Due to the high likelihood of file system issues and latency caused by flock, we would highly recommend not using this PHP function on your site.


Was this answer helpful?

« Back