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.