all blog posts


Architecture Series: Static Website

In the first installment of the Architecture Series, we will look at how the static part of this website is hosted.

Serverless

The infrastructure for CloudBanshee is completely serverless. For those of you unfamiliar with the term, serverless refers to cloud technologies which:

  • are a managed service
  • require no maintenance of servers, OS, software or libraries
  • are pay per use

Using serverless technologies makes it very easy to quickly deploy applications, without worrying about the underlying infrastructure. Because of its pay per use model, the cost will be very low (often free!) for small website, while the price will go up when you get more visitors. This way, the price tag grows with your customer base and revenue.

S3 Example

In Amazon's object storage service (Amazon Simple Storage Service, or S3) creating buckets is free. Once you start reading and writing files, you pay:

  • $0.005 per 1,000 PUT, COPY, POST or LIST requests
  • Requesting files from S3 costs $0.0004 per 1,000 requests
  • Plus $0.0007 per GB of data returned by S3 select
  • For storage, you pay $0.023 per GB per Month

S3 is fully managed, which means you have no worries about how the data is stored. You only need to know that it is stored, with 99.999999999% durability and 99.99% availability. Your files are accessible through CLI, SDKs, APIs and HTTP requests.

Hosting Static Content

Generally, there are two types of website content; static and dynamic. As the names imply, static content doesn't change often, while dynamic content might change with every request, or might be different for separate users. If a website contains images, for example, that is most like static content. If the website contains a "currently logged in users" ticker, or shows your personal content and friends, that's dynamic content.

From an infrastructure point of view, the two types require very different systems. Static content requires no processing, so you can store it in object storage like S3, and it's easily cacheable. Dynamic content generally needs a server running a backend application, for example written in Python, Java or PHP. This application might connect to a database to look up what content should be displayed.

CloudBanshee

The bulk of CloudBanshee is static content, consisting of HTML, CSS and Javascript. All of this is stored in an S3 bucket without public access. When you're visiting https://cloudbanshee.com, you're actually visiting a CloudFront distribution. This distribution returns cached content from CloudFront Edge Locations. If cached content is not available, CloudFront uses an Origin Access Identity (OAI) to fetch the data from S3.

Static Files

Conclusion

That's it! We just need two services (three if you count IAM) to host this website and all its interactive content, as long as the interactive part is Javascript.

The file size of the website, including images, is in the 10's of megabytes. The number of S3 PUT requests is very low, they only occur when uploading files. The number of S3 GET requests scales with usage of the site, but most of it is cached at CloudFront.

CloudFront itself costs $0.085 per GB of outbound traffic and $0.0100 per 10.000 HTTPS requests.

All in all, if CloudBanshee would get 10,000 visitors per month (I wish!), each requesting 15 files on average for a total of 2MB, with a cache hit rate of 75%, the monthly cost would be:

  • Next to nothing for S3 GBs stored and PUT requests
  • $0.15 for 150,000 CloudFront HTTPS requests
  • $1.70 for 20GB of CloudFront Data Transfer
  • $0.015 for 37,500 S3 GET requests
  • $0.0035 for 5GB of S3 Data Transfer

Grand total: $1.8685 per month. Ka-ching!


Related blog posts


all blog posts