Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save media files on AWS with multiple EC2 instances on AWS

In my application; users can upload videos and I want to keep them on file system and not in database. If I use Amazon Web Services ( AWS ) and use only one EC2 instance with EBS ( for storage ) its fine. But if I use auto-scaling or multiple EC2 instances ; then if user uploads the video it gets saved on one of the EC2 ( associated with one of EBS ) . Next time if user logs in ( or if session stickiness is not there; then if the user's next request goes to another EC2 instance ) how will it access his video ?

What is the best solution for this problem ? Is using S3 the only solution but for that I cant simply do java.io.File .. I think then I will have to use AWS SDK api to access the uploaded videos.. but wont that be slower ?

Is there any better solution ?

like image 513
Deepak Singhal Avatar asked May 07 '12 04:05

Deepak Singhal


1 Answers

I would use Amazon S3. It's fast, relatively cheap and works well if you are using other Amazon Web Services.

You could upload to the EC2 instance first and use Simple Workflow Servie to transfer the files centrally automatically. This is also useful if you want to re-encode the video to a multiple bit-rates later.

like image 100
Ben Avatar answered Sep 29 '22 07:09

Ben