如何Instagram的Amazon S3吗? [英] How does Instagram use Amazon S3?

查看:153
本文介绍了如何Instagram的Amazon S3吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我上传文件到Amazon S3,当我需要一些洞察到Instagram的的工程。我刚开始使用S3和我想的Instagram是一个很好的模式可以遵循,因为他们每天上传数千张图片。我的应用程序有几分相似。用户上传图片,可以删除自己的图像,所有图像都是公开的。

I'm in need of some insight into Instagram's engineering when uploading files to Amazon S3. I'm just starting with S3 and I think Instagram is a good model to follow because they upload thousands of images each day. My app is somewhat similar. Users upload images, can delete their own images, and all images are public.

在我的项目,我创建一个文件夹preFIX对象,组织上传为每个用户。例如的用户名/文件名

In my project I'm creating objects with a folder prefix to organize uploads for each user. e.g. username/filename

我的目标网址是这样的:

My object URLs look like this:

https://s3.amazonaws.com/my_bucket/username/28c3d2c6ec098bd077d6b9cb5f13869d.jpg

但Instagram的:

but Instagram:

http://distilleryimage7.s3.amazonaws.com/f4947c1004ca11e2a0c81231380ff428_7.jpg

我猜 distilleryimage7 是桶的名字。我不知道有什么优势此类URL都有。我也猜的Instagram不使用在一个桶桶文件,并存储所有图像。

I'm guessing that distilleryimage7 is the bucket name. I'm not sure what advantage this type of URL has. I'm also guessing that Instagram doesn't use bucket "files" and stores all images in one bucket.

请分享S3任何的最佳做法。

Please share any best practices in S3.

推荐答案

这个URL实际上是一个是默认支持通过S3。对于美国和大多数水桶,你可以做一个特殊的DNS解析,它允许你使用任何

This URL is actually one that is supported by default by S3. For US and most buckets you can do a special DNS resolution which allows you to use either:

http://my_bucket.my_domain.com

对于某些张家到你自己的记录或:

With some changs to your own records or:

http://my_bucket.s3.amazonaws.com

如果你不想改变任何A记录(一个小底漆:<一href="http://docs.amazonwebservices.com/AmazonS3/latest/dev/VirtualHosting.html#VirtualHostingCustomURLs" rel="nofollow">http://docs.amazonwebservices.com/AmazonS3/latest/dev/VirtualHosting.html#VirtualHostingCustomURLs).

If you don't want to change any of your A records (a small primer: http://docs.amazonwebservices.com/AmazonS3/latest/dev/VirtualHosting.html#VirtualHostingCustomURLs).

此类URL的优点当然是使用subodomains某些资产,使加载在浏览器更快的共同思想。

The advantages of this type of url is of course the common thought of using subodomains for certain assets to make loading faster in the browser.

当然,这是一个修复。一个被其他网站,如Facebook,Twitter和YouTube是使用完全不同的域这种东西。这有助于因为它是专门为这些资产设计(无饼干应该存在于这些领域要么)。

Of course this is a fix. One used by other sites such as Facebook, Twitter and Youtube is to use a whole different domain for this kind of stuff. This helps since it is a stripped out domain specifically designed for these assets (no cookies should exist on these domains either).

因此​​,这不是一个真正的的最佳的S3的做法,但普遍比较Web开发,占地如何计划和布局在生产环境中的网站更广泛的观点。

So this isn't really a best practice of S3 but more of web development in general and covers a much wider view of how to program and layout a site in a production environment.

是Instagram的将家中所有的文件在一个巨大的单斗,这是最有可能这样做的最明智的方法,然后当你大,你会复制水桶的部分地区和整个地区并依赖于需求的子区域将它们分割或者ping他们CloudFront的像Vimeo的一样。

Yes Instagram would house all files in a huge single bucket, this is most likely the most sane method of doing this and then when you get big you would replicate parts of the buckets and split them across regions and sub regions dependant upon demand or ping them to cloudfront like Vimeo does.

读完这进一步,我意识到这也是Instagram的并不在一个水桶容纳一切。有点不可思议真的,尤其是水桶必须唯一命名在整个S3,包括其他人的帐户。因此他们可能不直接使用用户名,除非该桶的名字尚未被采取。

After reading this further I realised too that Instagram does not house everything in one bucket. A bit weird really, especially since a bucket must be uniquely named across the whole of S3 including other peoples accounts. As such they probably don't use the username directly unless that bucket name hasn't already been taken.

有巨大的好处,这样做虽然。就像每个用户,每个用户的CloudFront的复制但也有缺点:

There are huge benefits to doing this though. Like replication per user and cloudfront per user however there are also downsides:

  • 很多单独的HTTP请求时,很多用户图像显示,不够公平这是所有到S3域名,但我不能确定你被允许搜索引擎优化和浏览器有多少子域利用它(我认为6在IE6)。

  • A lot of separate http requests when many users images are shown, fair enough it is all to S3 domain but I am unsure how many subdomains you are allowed for SEO and browsers to take advantage of it (i think 6 in IE6).

备份和复制也很难,因为你需要每个用户做不是为单个桶。

Backup and replication can be harder since you would need to do per user not for a single bucket.

移动水桶CDN等可能会有问题,因为你又要每个用户做到这一点。

Moving buckets to cdn etc can be problematic since you again have to do it per user.

我觉得我记得看到一个最大限制为S3的桶,所以我不确定这会如何扩大有效TBH。

I think I remember seeing a max limit for buckets in S3 so I am unsure how this will scale effectively tbh.

这篇关于如何Instagram的Amazon S3吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆