简体   繁体   English

如何在AWS上使用多个EC2实例保存媒体文件

[英]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. 如果我使用Amazon Web Services(AWS)并且只使用一个带有EBS的EC2实例(用于存储)则可以。 But if I use auto-scaling or multiple EC2 instances ; 但是如果我使用自动缩放或多个EC2实例; then if user uploads the video it gets saved on one of the EC2 ( associated with one of EBS ) . 然后,如果用户上传视频,则将其保存在EC2之一(与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 ? 下次如果用户登录(或者如果会话粘性不存在;那么如果用户的下一个请求转到另一个EC2实例),它将如何访问他的视频?

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 ? 使用S3是唯一的解决方案,但为此我不能简单地做java.io.File ..我想我将不得不使用AWS SDK api来访问上传的视频..但不会那么慢?

Is there any better solution ? 有没有更好的解决方案?

I would use Amazon S3. 我会使用Amazon S3。 It's fast, relatively cheap and works well if you are using other Amazon Web Services. 如果您使用其他Amazon Web Services,它速度快,相对便宜并且运行良好。

You could upload to the EC2 instance first and use Simple Workflow Servie to transfer the files centrally automatically. 您可以先上传到EC2实例,然后使用Simple Workflow Servie自动集中传输文件。 This is also useful if you want to re-encode the video to a multiple bit-rates later. 如果您希望稍后将视频重新编码为多个比特率,这也很有用。

You need to setup NAS. 你需要设置NAS。 It can be NFS or something like GlusterFS. 它可以是NFS或类似GlusterFS的东西。 The later is modern and it scales well... 后者是现代的,它很好地扩展......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM