Tuesday, September 17, 2013

Checking the amazon cloudfront edge-location in use

Sponsored Links
You have uploaded your files in Amazon S3 or Custom Origin. Created a cloudfront distribution. You checked and everything is working. Amazon has started new edge-locations in India. Mumbai and Chennai. How can you check your files are served from nearest edge? Or is it served from far edge? Then you have to change something. Getting the content from the nearest edge will reduce the latencies and improve the quality of service.

You can verify this two ways.

1) You can check Using the Amazon test tool. Easiest way.
2) Enable the cloudfront logs and check the logs. Little painful. But worth it.


We will see each method.

1) Using the Amazon aws cloudfront testing tool.

Go to the AWS Cloudfront testing tool

Amazon aws cloudfront testing tool
Cloudfront Testing Tool


In the tool give the url of the file you want to check the delivery edge-location. Reference ID you can give your email id.

Output will be as follows:

Destination Edge Location server-54-230-156-99.sin3.r.cloudfront.net
Anycast DNS Edge Location ns-sin2-02.cloudfront.net.sin2
Resolver IP 173.194.97.19

Response Header HTTP/1.1 200 OK
Content-Type: video/mp4
Content-Length: 35437375
Connection: keep-alive
Date: Mon, 16 Sep 2013 05:33:37 GMT
Last-Modified: Thu, 05 Sep 2013 10:18:03 GMT
ETag: 9db1e9ffd1528dfdfgfdcd70ff6c5a5cfe
Accept-Ranges: bytes
Server: AmazonS3
Via: 1.0 0348321a11c19f53456565454489.cloudfront.net (CloudFront)
X-Cache: Miss from cloudfront
X-Amz-Cf-Id: m004JaCC6454545435dcfdg2ppar1NQjin7zFd7V9Rc9kXgSyg==

sin2/sin3 means it was served from Singapore.

2) Using the cloudfront logs.


For this first you need to configure logging for the corresponding cloudfront distribution. Select the distribution and edit settings. Mark the logging as ON. Create a bucket for cloudfront logs in s3 and select that bucket for logs. Save it.

Checking the amazon cloudfront edge-location in use
Configuring logs for cloudfront


Now go to the s3 bucket for logs and you can see lot og gzip compressed files. Download any files and uncompress it and open it. You can see the log as given below.

2013-09-11 09:48:58 SIN2 13909 122.172.247.48 GET abcdefghi.cloudfront.net /ads/MPAds/LG/image/d9.png 200 http://abcdefghi.cloudfront.net/ads/MPAds/LG/page.html Mozilla/5.0%20(Linux;%20U;%20Android%204.0.4;%20en-us;%20LukupMedia%20Build/IMM76D)%20AppleWebKit/534.30%20(KHTML,%20like%20Gecko)%20Version/4.0%20Safari/534.30 - - RefreshHit CdDZdfdfd5quO-pwZykLFPYCrufdfdfdemAheGkWWl-fpm2lZEXObZXON5w==

Again SIN2 means it was served from Singapore.
Sponsored Links

No comments:

Post a Comment

Be nice. That's all.