I have an EC2 instance running a basic LAMP stack as a webserver. Users can upload photos through my web application which are then stored in a directory and recorded in MySQL. Typically these upload as fast as a user's internet upload speed allows.
Unfortunately, multiple users have been reporting that sometimes photo uploads are slowing down - taking up to 2 minutes per photo, while on other sites the users are able to upload much faster.
How can I optimize Apache (I'm assuming it's Apache?) to not become a bottleneck? Could this issue be resolved with MPM Preforking? Or is it possibly a database locking issue?
Some additional stats of this setup (it's pretty vanilla):
Instance Type: t2.small
EBS-optimized: False
PHP v5.4
Server version: Apache/2.4.18 (Amazon)
The only other thing that I'm considering relevant is that when a photo is uploaded, it's resized via Imagick to a thumbnail size (which is obviously a bit CPU intensive, but normally it's quite fast).
This kind of issue can be because of many reasons. But among the variables that you can control, You can start with network throttling. Basically suppose that there are ten users on your application. All with same upload speed . When they all simultaniously try to upload images. assume nine would get good speed. But because your server can only have a fixed transmission rate which all the nine guys are using, even though the tenth one is with same network performance, he will be uploading image slower. To handle this problem, you limit the speed per connection in your server, which is also called network throttling. Configuring the same in apache could be found here. But again this is just a speculation and in real life there can be many factors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With