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?