Question:
Regarding the slow upload speed of php files, is there any optimization method?
1. The average size of uploaded files is about 10M
2. I am currently using apache. I heard that changing to nginx can speed up the process?
Solution:
PHP-FPM will not be blocked during the file upload process, because Nginx will only hand it over to PHP-FPM once after receiving the uploaded content.
Worker processes of Nginx and PHP-FPM Only 1 is opened each.
Upload images at 2KB per second:
time trickle -s -u 2 curl \ -F "action=info.php" \ -F "upload_file=@linux.jpeg;type=image/jpeg" \ -F "submit=提交" \http://www.example.com/app/info.phpsudo netstat -antp|egrep "curl|nginx|fpm"
Found that only nginx and curl are in the ESTABLISHED state, and neither nginx nor fpm is blocked.
top -p 4075 可见Nginx单线程. sudo strace -p 4075 可见Nginx调用recvfrom接收数据并且pwrite保存数据. sudo strace -p 13751 可见PHP-FPM是在Nginx接收完成用户上传的数据时才获取数据.
Slow upload is mainly due to bandwidth problems, maybe user bandwidth, or It may be that the server bandwidth is not enough.
The above is that the php file upload speed is too slow. Is there any optimization method? Content, for more related content, please pay attention to the PHP Chinese website (www.php.cn)!