File uploads are slower than user network upload speeds on Apache (EC2)

I have an instance of EC2 that runs the main LAMP stack as a web server. Users can upload photos through my web application, which is then saved in a directory and written to MySQL. Usually they load as fast as the download speed of Internet users.

Unfortunately, many users report that sometimes downloading photos slows down - up to 2 minutes per photo, and on other sites users can upload much faster.

How can I optimize Apache (I assume it is Apache?) So as not to become a bottleneck? Is it possible to solve this problem with MPM Preforking? Or could it be a database lock problem?


Some additional settings for this setting (this is pretty vanilla):

Instance Type: t2.small EBS-optimized: False PHP v5.4 Server version: Apache/2.4.18 (Amazon)

The only thing that I think is appropriate is that when loading a photo, it was changed using Imagick to the size of the thumbnail (which obviously requires an intensive processor, but usually it is pretty fast).

+5
source share
2 answers

Lots of remaining information, for example, what you use, what are your specifications. The first thing I would like to do is increase your memory through the php.ini file.

set ('memory_limit', '64M'); (the shaft is installed on 256 m OR change it globally in php.ini (in Lampp located in '\ lampp \ php \ php.ini'):

memory_limit = 8M // find this "memory_limit" and configure it according to your needs. After that restart apache ...

ATTITUDE TO PIC. yellow should be next.

enter image description here

+1
source

This problem can be caused by many reasons. But among the variables that you can control, you can start by throttling the network. Suppose your application has ten users. All with the same download speed. When they all simultaneously try to upload images. suppose nine would get a good speed. But since your server can only have a fixed bit rate, which all nine guys use, although the tenth has the same network performance, it will load the image more slowly. To deal with this problem, you limit the connection speed on your server, which is also called network throttling. The configuration in apache can be found here . But again, this is just speculation, and in real life there can be many factors.

0
source

Source: https://habr.com/ru/post/1246268/


All Articles