nginx - 使用 NGINX 上传图像文件需要很长时间?
问题描述
我正在尝试使用 gunicorn、nginx、flask 和 MySQL 上传一个简单的 .png 图像,但是上传一个 5 mb 的图像需要 10 秒?我正在运行一个 ec2 微实例,但上传时 CPU 使用率低于 30%。
我的烧瓶代码 # 帖子名称为每个图像使用唯一 ID post_name = str(postID) + '_post.png' destination = os.path.join(target, post_name)
c.execute('UPDATE posts set filename=%s, filetype="picture"
where postID=%s',
(destination, postID))
file.save(destination)
我的 nginx 配置
location / {
include proxy_params;
client_max_body_size 250M;
proxy_pass http://127.0.0.1:8000;
root /home/ubuntu ;
client_body_buffer_size 8M;
}
解决方案
在声明上传速度很慢之前,请在其他地方进行测试。EC2 带宽取决于实例大小,而 t2.micro 没有太多。请参阅https://cloudonaut.io/ec2-network-performance-cheat-sheet/
推荐阅读
- r - 如何在使用 xlsx 文件进行循环后放置列名
- rxjs - 我们是否需要取消订阅 rxjs `from` 运算符
- r - 如何在 sjPlot 中提高线条质量和编辑轴
- css - 如何在悬停css上应用多个元素
- office-js - 从 Excel 加载项访问 Word API,反之亦然
- react-native - 如何在本机反应中隐藏顶部导航栏
- python - 使用 LSTM 时结果中的行数错误
- python - pytest中的导入路径
- tensorflow - 如何在 tf.distribute.experimental.MultiWorkerMirroredStrategy 中合并分布式工作人员的结果
- websphere - 在“ websphere 中的 dropins 文件夹下有多个战争文件如何为每个战争生成单独的日志文件”