我想上传一个mp3文件到我的s3存储区。我正在使用this 包。它太慢,因为需要5分钟才能上传5MByte。seferov aws s3 symfony2存储区上传速度太慢
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
我的钱是在俄勒冈州(小例子),我的s3桶在爱尔兰。我从意大利上传(450kbps上传)。直接从aws桶控制台上传相同的文件大约需要一分钟。
你有什么建议来加速它? 将我的实例移至爱尔兰将会明显改变上传时间? 升级实例会更好,然后移动它?
您可能想要通过在战略点处记录一些时间戳来对基准代码进行基准测试。如图所示,您似乎从意大利上传到俄勒冈州,之后第一阶段完成,然后该实例从俄勒冈州上传至爱尔兰。哪一部分很慢,第一个还是第二个? –
@ Michael-sqlbot查看更多信息的编辑。看起来第二个是缓慢的 –