分类: 数据库开发技术
2009-04-25 07:33:05
Now that you know the and are equipped with tools to manage files on S3, let’s focus on how data gets stored on Amazon S3 using Buckets.
Just like a bucket holds water, Amazon buckets are like a container for your files. You can name your buckets the way you like but it should be unique across the Amazon system.
The suggestion is to follow a domain naming convention, like downloads.xyz.com or media.xyz.com.
This is recommended because xyz.com is very likely to be unique and this also lets you easily map your existing web domains or sub-domains directly to Amazon S3 by adding/changing your DNS CNAME entries.
So in the example above - media.xyz.com bucket on Amazon S3 will correspond to a web address like while download.xyz.com will correspond to a URL like
Now if you upload an image (say animals.jpg) and drop it inside the media bucket (media.xyz.com) - that image can be accessed on the Internet using the following address:
animals.jpg
So you can map the media.xyz.com domain to and then your image can be accessed using the simple URLs like media.xyz.com/animals.jpg instead of using that complex Amazon URL - animals.jpg
Later, if you move from Amazon S3 to another cloud hosting from say Microsoft or Google, just change the CNAME entries and none of the URL will break.
Another important part is that Amazon S3 defaults file access to READ/WRITE only by the owner and thus other people may not be able to access your files unless you set the right file attributes (something like chmod in Unix).
For publicly accessible files (like web images on your blog or public downloads), you should set them to “World:Read” and “Owner:Write”. You can set the File Attribute after you upload a batch to S3 or change the default setting.
Why You May Want to Use Amazon S3 Storage ?
There are two reasons why you may want to host files with Amazon S3 - it’s very reliable and you pay only for what you consume ( & S3 calculator).
S3 pricing is something like this - you pay 15 cents per GB-Month of storage and 20 cents per GB of data transferred (applicable when you are uploading or downloading data from Amazon S3).
I use S3 primarily for hosting media files (images, audio and video) and here’s how Amazon bills me:
* I’ve about 1GB of media files stored on S3 = $0.15 /mo (storage)
* Suppose I upload about 0.2GB (200MB) each month = $0.02 /mo (data transfer in)
* Last month, my media files consumed bandwidth of about 25GB = $4.25 /mo ($0.170 /GB /mo for the first 10TB)
* My upload (PUT, POST, LIST) requests are less = $0.01 /mo (for the first 1,000 requests)
* My download (GET) requests are very less = $0.01 /mo (for the first 10,000 requests)
Thus, the total cost at the end of the month would be $4.44! Let’s assume that I follow this pattern (even increasingly on the upper bracket) for the next 10 years, I’m likely to pay just about (4.44 + 4.5) = $8.95, calculated that I increased the storage to 30GB at the end of 10 years (roughly about 200+ MB a month). Even if my bandwidth consumption multiplies to 1TB, I would still be paying just (8.95 + 17.0) = $25.95 in the year 2018.
So, storing about 30GB of files with a bandwidth consumption of 1TB a month on a highly scalable, durable hardware, maintained by experts at the cost of just about $25 a month; that’s just awesome.