Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File uploads slower than user's network upload speed on Apache (EC2)

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

like image 491
Jeremy Penrod Avatar asked Apr 01 '16 21:04

Jeremy Penrod


1 Answers

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.

like image 53
georoot Avatar answered Oct 22 '22 00:10

georoot