【问题标题】:seferov aws s3 symfony2 bucket upload too slowseferov aws s3 symfony2 存储桶上传太慢
【发布时间】:2016-03-02 00:08:01
【问题描述】:

我想更快地将 mp3 文件上传到我的 s3 存储桶。我正在使用this 捆。上传5MByte需要5分钟,太慢了。

public function labelAddSongAction($label){

    $start = microtime(true);

    $path = $this->request->files->get('file')->getRealPath();

    $client = $this->get('aws.s3');

    $aws_conn = microtime(true);

    $song = $this->getDoctrine()->getRepository("WebsiteDeviceBundle:Labels")->addSong(
        $label,
        $this->request->get('title'),
        $this->request->get('artist'),
        $this->request->get('album'),
        $this->request->get('genre'),
        null,
        $this->request->get('duration'),
        $this->request->get('hash')
    );

    $db = microtime(true);

    $result = $client->putObject(array(
        'Bucket' => "bucket",
        'Key'    => 'masters-'.$song->getId().".".$this->request->files->get('file')->getClientOriginalExtension(),
        'SourceFile'   => $path
    ));

    $putobj = microtime(true);

    //dboperation with the result

    $end = microtime(true);

    die(
        ($aws_conn-$start)." aws conn<br>".
        ($db-$aws_conn)." db<br>".
        ($putobj-$db)." putobj<br>".
        ($end-$putobj)." db2<br>"
    );

}

可以,但是太慢了。

这是死机时的输出(此尝试使用 3Mbyte 文件,因为更多,连接将超时)

0.018278121948242 aws 连接
0.014150857925415 分贝
2.4144551753998 putobj
0.0062119960784912 db2

我的 istance 在俄勒冈州(小实例),我的 s3 存储桶在爱尔兰。我从意大利上传(450kbps 上传)。直接从 aws 存储桶控制台上传相同的文件大约需要一分钟。

为了加快速度,您有什么建议? 将我的实例移至爱尔兰会显着改变上传时间吗? 升级实例然后移动它会更好吗?

【问题讨论】:

  • 您可能希望通过在战略点记录一些时间戳来对此代码进行基准测试。如图所示,您似乎正在从意大利上传到俄勒冈州,并且在第一阶段完全完成后,实例正在从俄勒冈州上传到爱尔兰。哪个部分慢,第一部分还是第二部分?
  • @Michael-sqlbot 查看包含更多信息的编辑。看来第二个很慢

标签: php symfony amazon-web-services file-upload amazon-s3


【解决方案1】:

将我的存储桶移动到俄勒冈地区(运行实例的地方)后,输出为

0.017653942108154 aws 连接
0.015467882156372分贝
0.36472797393799 putobj
0.006134033203125 db2

5Mb 文件(不到一分钟)。仍然很慢,但这次可能取决于我的上传/下载互联网连接速度以及我在意大利且服务器在俄勒冈州的事实。

我的操作的服务器执行时间还可以。

【讨论】:

    猜你喜欢
    • 2018-07-13
    • 2015-12-07
    • 2018-10-11
    • 1970-01-01
    • 2018-04-25
    • 2017-03-13
    • 1970-01-01
    • 2017-09-17
    • 1970-01-01
    相关资源
    最近更新 更多