2
votes

I maintain a 'hobby' website to experiment with AWS technologies. Because it's a pure hobby, I am trying to keep its costs as low as possible, and only use those services that are absolutely necessary.

Over the months, the website has started to generate some traffic, about 30-50 hits per day, and on some days it has had up to 1K hits per day.

I am using CloudFront (CF) for the main purpose of having HTTPS and having a way to connect my domain with my S3 website bucket, but the costs have been going up as a result of the increase in hits.

Obviously, at this stage, the costs are manageable (few dollars p. month), but as I said my goal is to keep costs to an absolute minimum, and CF is starting to be the lion share of my costs.

Reviewing the CF costs in Bill Details, show me that HTTPS requests and especially Bandwidth make up the lion share of the costs.

I am looking for a way that allows me to continue using CF for the HTTPS and for having a way to point my domain securely serve from the S3 bucket, but to reduce costs resulting from the requests and bandwidth.

The website is static and entirely hosted on S3. It contains:

  • an index.html - auto-updated every hour
  • 10 category pages (250 kilobyte in size each) - auto-updated every hour, they contain links to the detail pages
  • < 1,000 details pages (100 kilobyte in size each) - these are created once, and then never changed again
  • < 1,000 images (50 kilobyte in size each) - each detail page has 1 image, their behaviour is the same as details pages

My CF configuration is as follows:

  • no Origin Custom Headers
  • Behaviour:
    • Path pattern: Default (*)
    • Viewer protocol policy: Redirect HTTP to HTTPS
    • Cache Based on Selected Request Headers: Whitelist
    • Whitelist Headers: Referer
    • Object Caching: Customize
    • Min. TTL: 0
    • Max. TTL: 31536000
    • Default TTL: 0
    • Forward Cookies: None
    • Query String Forwarding and Caching: None
    • No geo restrictions

Analysing the majority of CF cost being Bandwidth, this tells me that it may be the page and image files that is causing this. I.e. when people load my pages, and the image files are being served, it adds up to 100 kb + 50 kb per page.

Based on my research on CF, I suspect that the Path Pattern and TTL parameters is what needs to be optimised here to achieve a cost reduction. If someone could point me in the right direction that would be great.

1
What is the average image size?Rodrigo M
Images are 59 kilobyte on average and pages are 100 kilobyte on average. I hadn't realised the pages made up so much size. I shall edit my post.AHL

1 Answers

7
votes

Bandwidth costs are proportional to the amount of data retrieved from your website.

  • Amazon S3: 9c/GB
  • Amazon CloudFront: 8.5c/GB to 17c/GB depending upon location

Some ideas to reduce your costs:

  • Change the CloudFront distribution to use Price Class 100, which only serves traffic from the lower-cost locations. Users in other locations will have slower access, but you'll save money!
  • Increase your default TTL so that content remains cached longer, resulting in fewer repeat requests.
  • Activate and examine CloudFront Access Logs to analyse incoming traffic. It might be that a lot of requests are coming from spiders and bots. You can limit such access by creating a robots.txt file.
  • Reduce the filesize of images by lowering quality. The trade-off in quality might be worth the cost savings.
  • Make a less-popular website. That will lower your costs! :)