文件上传速度低于用户在Apache(EC2)上的网络上传速度 [英] File uploads slower than user's network upload speed on Apache (EC2)

查看:96
本文介绍了文件上传速度低于用户在Apache(EC2)上的网络上传速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行基本LAMP堆栈的EC2实例作为Web服务器.用户可以通过我的Web应用程序上传照片,然后将其存储在目录中并记录在MySQL中.通常,这些上传速度会达到用户的互联网上传速度所允许的速度.

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.

不幸的是,多个用户报告说,有时照片的上传速度变慢-每张照片最多需要2分钟,而在其他网站上,用户可以更快地上传.

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.

如何优化Apache(我假设它是Apache?)以免成为瓶颈?使用MPM Preforking可以解决此问题吗?还是数据库锁定问题?

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)

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

我认为与此相关的另一件事是,当上传照片时,它会通过Imagick调整为缩略图大小(这显然需要占用大量CPU,但通常很快).

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

推荐答案

这种问题可能是由于多种原因造成的.但是在您可以控制的变量中,您可以从网络限制开始.基本上假设您的应用程序上有十个用户.全部具有相同的上传速度.当他们全部同时尝试上传图像时.假设九将获得良好的速度.但是,因为您的服务器只能具有所有九个人使用的固定传输速率,即使第十个人具有相同的网络性能,他的图像上传速度也会变慢.要解决此问题,请限制服务器中每个连接的速度,这也称为网络限制. 可以在apache中配置相同的文件这里.但这又只是一种推测,在现实生活中可能有许多因素.

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.

这篇关于文件上传速度低于用户在Apache(EC2)上的网络上传速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆