How to Improve Amazon S3 Download Performance with a CDN
January 2, 2013 | Justin Dorfman
Among the thousands of origin servers we support, Amazon's Simple Storage Service (S3) is the most popular (especially among our Enterprise CDN customers). And although S3 is great at warehousing content, it's not designed with the price and performance considerations of a CDN.
Say it with me: S3 is not a CDN — David Cramer (@zeeg) February 3, 2013
Suppose you're pushing 1TB a month. On S3 that costs you $122.76/month, served from a single location. With a MaxCDN Business Package, you could handle that same 1TB for $79, distributed across 10+ data centers worldwide. This results in massive load time improvements for users as you can see here:
|Amsterdam, NL||1,751ms||171ms||-1,580ms (90.23%)|
|Chicago - GLC||1,208ms||120ms||-1,088ms (90.62%)|
|New York - VZN FIOS||1,242ms||591ms||-651ms (52.41%)|
Today let's walk through creating a new S3 bucket on AWS, creating a Pull Zone on MaxCDN, and measuring the real-world performance of our CDN.
Step 1: Create Your S3 BucketLogin to your AWS account (https://console.aws.amazon.com/s3/home) and select "Create a Bucket". Next upload an object and check to see if it is available to the public:
$ curl -I http://s3.amazonaws.com/netdna/Max-Juggling-800x1228.png HTTP/1.1 200 OK x-amz-id-2: uXxRZBOYCBapOWjbhgeyyoKuOEnCxf+yi4W7BYjDuSvQluIBpbvx8EEqEjr4miPg x-amz-request-id: 663DBAC989E2992D Date: Thu, 03 Jan 2013 00:25:42 GMT Last-Modified: Wed, 02 Jan 2013 21:31:21 GMT ETag: "c0a8b02d44d6771eeb5d034e941a62ee" Accept-Ranges: bytes Content-Type: image/png Content-Length: 350404 Server: AmazonS3
Step 2: Create Your (CDN) Pull ZoneOur next step is to create a Pull Zone on MaxCDN. [Updated] Follow these steps: http://support.maxcdn.com/howto/create-a-pull-zone/ Now that the Pull Zone is provisioned, check to see if the image is cached on the CDN:
$ curl -I http://s3pullnetdna.jdorfmanqa.netdna-cdn.com/Max-Juggling-800x1228.png HTTP/1.1 200 OK Date: Thu, 03 Jan 2013 00:13:02 GMT Content-Type: image/png Content-Length: 350404 Connection: keep-alive x-amz-id-2: zXcIev2CEQbxeyukY07YljRGt5OjbjupEXREuXvtY4T8yauyXsJFp4QHh3wkfYy3 x-amz-request-id: A5F6FE3774D58024 Last-Modified: Wed, 02 Jan 2013 21:31:21 GMT ETag: "c0a8b02d44d6771eeb5d034e941a62ee" Server: NetDNA-cache/2.2 X-Cache: HIT Accept-Ranges: bytesNotice the 2 new headers in the response:
- Server: NetDNA-cache/2.2
- X-Cache: Hit
Step 3: Measure PerformanceUsing Chrome's Developer Tools, we can peek at the file load time from the browser's perspective (well under a second): Catchpoint, we ran a detailed 4-hour performance test. As you can see, there's a huge improvement when using a CDN vs. S3.
- Average response: CDN (300ms) vs. S3 (1.8 - 2.7s)
- Median response: CDN (200 - 400ms, worldwide) vs. S3 (1.2 - 4.2s, worldwide)