Reputation: 2186
I want to upload an mp3 file faster to my s3 bucket. I'm using this bundle. It's too slow as it takes 5 minutes to upload 5MByte.
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>"
);
}
It works, but too slow.
here is the output when it dies (this try is with 3Mbyte file because more, the connection will goes timeout)
0.018278121948242 aws conn
0.014150857925415 db
2.4144551753998 putobj
0.0062119960784912 db2
My istance is in Oregon (small instance) and my s3 bucket is in Ireland. I'm uploading from Italy (450kbps upload). Uploading the same file directly from the aws bucket console takes about a minute.
What suggestions do you have in order to speed it up? Moving my instance to Ireland will change significately the upload time? Upgrading the instance will be better then move it?
Upvotes: 2
Views: 223
Reputation: 2186
After moving my bucket to the Oregon region (where it is running the instance), the outputs are
0.017653942108154 aws conn
0.015467882156372 db
0.36472797393799 putobj
0.006134033203125 db2
5Mb file (less then a minute). Still slow, but maybe this time depends on my upload/download internet connection speed and on the fact that I'm in Italy and the servers are in Oregon.
The server execution time for my operation is ok.
Upvotes: 0