I would like to ask everyone, when I compress the file, no matter how I set the timeout time, the compression request prompts 504 timeout in 1 minute, nginx php is set up but it does not work, the management software is phpstudy, the system centos7.
There is another question. When compressing ZipArchive, I want to increase the compression speed. How to deal with it? The maximum server load during compression is only 16%.
Regarding the first question, if you have set the timeout in Nginx and PHP, but still encounter a 504 timeout error, you can try the following solutions: 1. Check the timeout setting of PHP-FPM: open php -fpm.conf file, find the `request_terminate_timeout` parameter and increase its value to a longer time (in seconds) and restart PHP-FPM. 2. Check the timeout setting of Nginx: Open the nginx.conf file, add or modify the following parameters in the `http` block:
3. Check the server resource restrictions: Ensure that the server's resources (CPU, memory, disk space) is sufficient to handle compression requests. If the server resources are insufficient, the compression process may take a long time and trigger a timeout. 4. Adjust compression algorithms and parameters: Some compression algorithms may be faster than others. You can try using a different compression algorithm or adjust ZipArchive's parameters to improve compression speed. For example, you can set a different compression method using the `setCompressionMethod()` method, or adjust the compression level using the `setCompressionLevel()` method. Regarding the second question, if the server load only reaches 16%, it means that the system resources are not fully utilized. This may be due to the fact that the ZipArchive compression process is dominated by CPU calculations rather than disk or network operations. In this case, you can try the following methods to improve compression speed: 1. Use a faster compression algorithm: Some compression algorithms are faster than others. You can try using a faster compression algorithm such as the Deflate algorithm (`ZipArchive::CM_DEFLATE`). 2. Adjust compression parameters: By adjusting ZipArchive parameters, such as setting different compression levels, window sizes, etc., the compression speed may be affected. You can try and optimize according to the actual situation. 3. Parallel processing: If you have multiple files that need to be compressed, consider processing multiple files in parallel to increase the overall compression speed. For example, use multi-threading or a process pool to process multiple files simultaneously. Please note that when optimizing server performance and increasing compression speed, ensure sufficient system resources and avoid exceeding the server's capacity to cause performance problems. In addition, please remember to use server resources wisely and adhere to relevant regulations and best practices.