Amazon CloudFront Latency

+1 vote
This concerns AWS S3 and CloudFront for a web application.

If I let users upload files to the S3 bucket using the AWS SDK and make it available via CloudFront CDN, I face an issue that even when the files are uploaded and ready in the S3 bucket it takes a couple minutes before it is available in the CloudFront CDN URL. I am certain if this behaviour is normal
Apr 8, 2018 in Cloud Computing by hemant
• 5,750 points
189 views

3 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

In CloudFront’s defence:

Understand this that CloudFront pulls from CDN. Now the data that is being fetched from original server is uncached and this fetching happens in real time. So there won’t be any replication delays. CloudFront doesn't know about the content until it receives requests for it. So, all it does is fetch request from origin server, and cache it as appropriate, for serving subsequent requests.

Now what could be the problem?

This issue at hand may have to do something with "negative caching" – Now here a request wont work if it is typically done to avoid hammering the origin of whatever's being cached with requests that are likely to fail anyway.

Okay this is what happens normally:

By default, when your origin returns an HTTP 4xx or 5xx status code, CloudFront caches these error responses for five minutes and then submits the next request for the object to your origin to see whether the problem that caused the error has been resolved and the requested object is now available. Refer the link for more info:

— http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/custom-error-pages.html

Now if you try to download the file from that particular CloudFront edge before the upload into S3 is complete, S3 will return an error, and CloudFront -- at that edge location -- will cache that error and remember, for the next 5 minutes. So this is where if another request comes there could be trouble:

You can fix this though:

Specify the error-caching duration that is the  Error Caching Minimum TTL—for each 4xx and 5xx status code that CloudFront caches.

Refer this if needed

 Configuring Error Response Behavior.

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/custom-error-pages.html


I hope this helps

answered Apr 8, 2018 by brat_1
• 7,080 points
0 votes

To serve end users outside of China, we recommend using Amazon CloudFront, a global content delivery network (CDN) service that integrates with other Amazon Web Services to give developers and businesses an easy way to distribute content to end users with low latency, high data transfer speeds, and no commitments. Amazon CloudFront uses a global network of edge locations, located near your end users in the United States, Europe, Asia, South America and Australia. Amazon CloudFront edge locations are currently not available inside of China.

answered Aug 17, 2018 by Priyaj
• 56,100 points
0 votes

As observed in your comment, it seems that google chrome is messing up with your upload/preview strategy:

  1. Chrome is requesting the URL that currently doesn't have the content.
  2. the request is cached by cloudfront with invalid response
  3. you upload the file to S3
  4. when preview the uploaded file the cloudfront answers with the cached response (step 2).
    1. after the cloudfront cache expires, cloudfront hits origin and the problem can no longer be reproducible.
answered Oct 16, 2018 by Allisandro

Related Questions In Cloud Computing

0 votes
1 answer

When to use Amazon Cloudfront or S3

Amazon S3 is simple storage service for internet ...READ MORE

answered Jul 31, 2018 in Cloud Computing by ArchanaNagur
• 1,010 points
36 views
+4 votes
2 answers

Running JAR file on Amazon EMR created using Hadoop 2.7.5

I suggest you recompile the code or ...READ MORE

answered Oct 11, 2018 in Cloud Computing by findingbugs
• 4,730 points
155 views
+2 votes
4 answers

Scaling Amazon EBS Volume sizes

You can grow the storage or compress ...READ MORE

answered Oct 25, 2018 in Cloud Computing by prashant
39 views
+1 vote
1 answer

Having Trouble connecting to Amazon Elasticache Redis outside of Amazon

Well, bluntly speaking the answer is No. ...READ MORE

answered Apr 10, 2018 in Cloud Computing by code_ninja
• 5,690 points
247 views
0 votes
3 answers

Is it possible to redirect a domain to Amazon EC2?

Create an Elastic IP on the AWS ...READ MORE

answered Nov 30, 2018 in Cloud Computing by Abhinav
14 views
0 votes
1 answer

Where should I use Amazon Kinesis instead of SNS-SQS?

Your concern is very valid. These two ...READ MORE

answered Apr 17, 2018 in Cloud Computing by code_ninja
• 5,690 points
424 views
0 votes
1 answer

Differentiating Amazon EC2 API tools and AMI tools?

This is what AWS FAQ’s have to ...READ MORE

answered Apr 18, 2018 in Cloud Computing by hemant
• 5,750 points
61 views
0 votes
1 answer

Can you mirror Amazon S3 bucket using Amazon Glacier?

Yes you can mirror Amazon S3 bucket ...READ MORE

answered Apr 19, 2018 in Cloud Computing by brat_1
• 7,080 points
86 views
+4 votes
2 answers

Amazon S3 Permission problem - How to set permissions for all files at once?

This can be done by setting the ...READ MORE

answered Mar 27, 2018 in Cloud Computing by brat_1
• 7,080 points
29 views
+4 votes
6 answers

Creating Amazon Web Service (AWS) account (trial version) without giving up credit card details

Unfortunately, you can’t create an account on ...READ MORE

answered Mar 29, 2018 in Cloud Computing by brat_1
• 7,080 points
626 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.