Home > Backend Development > PHP Tutorial > Regarding the slow upload speed of PHP files, is there any optimization method?

Regarding the slow upload speed of PHP files, is there any optimization method?

PHP中文网
Release: 2023-03-01 08:22:01
Original
7751 people have browsed it

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"
Copy after login

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接收完成用户上传的数据时才获取数据.
Copy after login

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)!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template