Why are my Amazon S3 images loading slow?
Solution 1
If you're embedding the images, you should serve them through Amazon CloudFront (Amazon's CDN Service). CloudFront loads the image/file from S3 (or a custom origin) then caches it on their edge servers.
CloudFront Tutorial - http://www.hongkiat.com/blog/amazon-cloudfront-how-to-setup-cloudfront-to-work-with-s3/
Solution 2
S3 is just for Static Storage, by default it does not have the optimized performance, though there are ways to make it better.
Before you configure CloudFront, you should try enabling `Transfer Acceleration' on S3 bucket.
Source: https://docs.aws.amazon.com/AmazonS3/latest/userguide/transfer-acceleration.html
Benefits are,
- Your customers upload to a centralized bucket from all over the world.
- You transfer gigabytes to terabytes of data on a regular basis across continents.
- You can't use all of your available bandwidth over the internet when uploading to Amazon S3.
This comes at a price.. (https://aws.amazon.com/about-aws/whats-new/2016/04/transfer-files-into-amazon-s3-up-to-300-percent-faster/)
Pricing for Amazon S3 Transfer Acceleration is simple, with no upfront costs or long-term commitments. You simply pay a low, per-GB rate for data transferred through the service. The pricing is designed to be risk free: if Amazon S3 Transfer Acceleration isn’t likely to make a difference in the speed of an upload (like when you upload data over the short distance from a client in Tokyo to an S3 bucket in Japan), you won’t be charged anything extra for that upload. For more information on pricing, see Amazon S3 pricing.
Related videos on Youtube
Jason
Coding by morning, Coder by night. Specialising in helping startups in London create their MVP and launching. @Lovetheidea_co Recipes @BusinessCrowd
Updated on September 14, 2022Comments
-
Jason over 1 year
It seems like the images read from amazon s3 load really slow. I had the images on the same server as the website and it loaded super fast. Is it loading slow cause it has to access it from s3 now?
Is there nothing i can really do about it ??
Using this to read the image files:
$secure_link = gs_prepareS3URL("myAmazon."/thumb/thumb_".$id, $bucket); readfile($secure_link);
Function is from : http://www.richardpeacock.com/blog/2010/07/amazon-aws-s3-query-string-authentication-php
-
SuperStar518 over 4 yearsTutorial goes here - aws.amazon.com/getting-started/tutorials/deliver-content-faster