You are previewing Programming Amazon EC2.

Programming Amazon EC2

Cover of Programming Amazon EC2 by Flavia Paganelli... Published by O'Reilly Media, Inc.


Most simple web applications are built as three-tier architectures. You might not even be aware of this, as it is (most of the time) unintentional. The three tiers of these applications are:

  1. Data (usually kept in a relational database)

  2. Logic (dynamic content generated in a web or application server)

  3. Presentation (static content provided by a web server)

Over time, web development frameworks slowly lost the distinction between the logic and presentation levels. Frameworks like PHP, Ruby on Rails, and Django rely on Apache modules, effectively merging the logic and presentation levels. Only when performance is an issue will these two layers be untangled, mainly because the overhead of Apache is not necessary to serve semistatic content.

But there is another alternative: CloudFront. Amazon CloudFront is a content distribution network, designed to bring static content as close to the end user as possible. It has edge locations all over the world, storing your files and delivering them upon request. Perhaps we don’t need the edge locations yet, but we can use CloudFront for its scalability and to offload our application server. We’ll use CloudFront as the presentation tier in our three-tiered architecture.

Setting Up S3 and CloudFront

Amazon S3 is a regional service, just like EC2 and RDS, while CloudFront is a global service. S3 works with buckets, and CloudFront works with distributions. One CloudFront distribution exposes the content of one S3 bucket (one bucket can be exposed ...

The best content for your career. Discover unlimited learning on demand for around $1/day.