I've got a PHP file generating a large amount of JSON (~1.5 MB) through an Nginx server and PHP-FPM, running on macOS.
Occasionally (about 2% of requests), the outputted JSON becomes corrupted. The length of the body is always the same, however it looks like various chunks of bytes (of possibly various lengths) get reordered resulting in the corruption.
The random corruption never occurs when:
- Serving identical but static JSON files directly through Nginx without PHP.
- Generating the JSON directly from PHP using the command line.
The random corruption still occurs when:
- Having PHP
readfilea static JSON file, rather than dynamically generating the JSON itself.
- Other scripts generating large amount of data sent through PHP, even if it isn't JSON.
No errors in Nginx or PHP-FPM logs, everything else seems to be working normally. Nginx and PHP were installed through Homebrew, aer typically configured and are recent versions (although I've been dealing with this corruption for a year or so):
nginx version: nginx/1.17.3
PHP 7.1.23 (fpm-fcgi) (built: Feb 22 2019 22:19:35)
How might I debug this, or is there some configuration I can try to see if it fixes it?