title: Can high load cause PHP to not be able to write to a textfile?
body: <p>I have a PHP script which is under high load with multiple calls per second (originating from another computer). It's running on PHP 5.5.14 on an IIS server. Every request and response to the script is logged using </p>
  
  <pre><code>file_put_contents('log_2019-09-12.txt', $msg, FILE_APPEND);
  </code></pre>
  
  <p>Every request and response is also logged on the client computer, and there I see occasional PHP errors like this one:</p>
  
  <pre><code>PHP ERROR 2: file_put_contents(C:\\WWW\\project-x\\logs\\log_2019-09-11.txt): failed to open stream: Permission denied
  </code></pre>
  
  <p>These seem to happen about every ~140 minutes, usually there are 8 of them in a row and then things work for another ~140 minutes, handling several requests per second and logging successfully to the log file.</p>
  
  <p>Could it be that PHP is usually writing to an in-memory file and then actually writes the contents to disk every ~140 minutes, and that's what's causing this error? If so, how can I circumvent it?</p>