Search code examples
amazon-web-servicesamazon-s3amazon-cloudfront

Amazon s3 or cloudfront


I have most of my website traffic from India. Cloudfront, as far as I know, transfers data from the nearest data center. But it charges almost double $0.17 for data transfer to India compared to $0.09 in s3. Can I set the data center as some Asian country in s3 so as to serve the content almost equally fast or shall i rather go with cloudfront?


Solution

  • Amazon CloudFront is a content-distribution network that acts as a caching layer for web content.

    When a CloudFront distribution is created, you receive a special URL that is used to refer to traffic on CloudFront. When this URL is resolved, AWS will return an IP address that points to the closest CloudFront point-of-presence. "Closest" may actually mean "least latency" rather than geographically closest, since that give the fastest connection for users.

    The data transfer cost for CloudFront varies by the location from which traffic is served. Please note that this is not related to where the data "origin" is located -- you could be running a server out of the USA, but CloudFront is charged based on where traffic is from, which is close to the user. So, CloudFront would not be any cheaper if you changed the location of the origin data ("Region").

    If you are concerned at the high price of traffic from India, you can configure a Price Class that restricts the locations from which traffic is served.

    Price Class 100:

    • USA
    • Europe

    Price Class 200:

    • USA
    • Europe
    • Hong Kong, Philippines, S. Korea, Singapore & Taiwan
    • Japan
    • India

    Price Class All:

    • As above, plus:
    • South America
    • Australia

    So, configuring your CloudFront distribution for Price Class 100 would stop traffic being served from India, causing it to be served out of either the USA or Europe. This would be slower for your users, but would be cheaper for you.

    See: Amazon CloudFront pricing

    In comparing the price of Amazon CloudFront vs Amazon S3, the data transfer portion of S3 pricing is related to the S3 Region you are using. For example, traffic from S3 in Oregon is 9 cents. This is actually more expensive than CloudFront traffic served out of Oregon, which is 8.5 cents. Also, serving traffic directly from S3 does not cache content closer to users, so it would have higher latency.

    Bottom line: Serving cached traffic from CloudFront can typically be cheaper and faster for your users. Use Price Classes to limit the amount you will be charged for sending traffic from more-expensive locations.