【问题标题】:Uploading an image file with NGINX takes a long time?使用 NGINX 上传图像文件需要很长时间?
【发布时间】:2019-07-21 11:28:13
【问题描述】:

我正在尝试使用 gunicorn、nginx、flask 和 MySQL 上传一个简单的 .png 图像,但是上传一个 5 mb 的图像需要 10 秒?我正在运行一个 ec2 微实例,但上传时 CPU 使用率低于 30%。

我的烧瓶代码 # 帖子名称为每张图片使用唯一 ID post_name = str(postID) + '_post.png' 目的地 = 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;
}

【问题讨论】:

    标签: nginx flask gunicorn


    【解决方案1】:

    在声明上传速度很慢之前,请在其他地方进行测试。 EC2 带宽取决于实例大小,而 t2.micro 没有太多。见https://cloudonaut.io/ec2-network-performance-cheat-sheet/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-27
      • 2015-08-30
      • 1970-01-01
      • 2018-12-10
      • 2013-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多