Transitioning to Amazon S3 + CloudFront Media Delivery
Update on April 25, 2023:
After the transitioning to the Hugo platform, it is no longer convenient to upload pictures to S3. I will keep exploring options to host images on S3, but for time being images will be served locally.
Look at the above image. This might appear to be an ordinary GUNPLA picture, but notice the URL it’s coming from (media.kazumi.blog)… Yup, after a (whole night’s) preparation and work, the blog is finally using the Amazon S3 for media storage. From now on all pictures (and potentially videos) will be stored in Amazon S3 and accelerated via Amazon CloudFront.
What’s the benefit of that? So to understand that, I must explain some alternatives to it and the drawback of each
- Using 3rd party photo hosting (e.g. Flickr, PhotoBucket): I have been doing PhotoBucket for many years and, while the free version is great for very light uploads, it is otherwise limited in many aspects. For example, they limit the number of photos on your account, the resolution of photos, and they may show ads and watermarks on your pictures if you don’t pay up. Plus it is somewhat annoying to work with because you need to import each of the pictures as an individual URL and they are completely separated from the WordPress workflow.
- Hosting pictures on the blog: after I’m tired of the PhotoBucket workflow and the fact they disabled my account because I went over free tier, I decided to start hosting the photos myself on the same host that runs the website. Simple, free, works well with WordPress, BUT… it does use up the precious disk space the VPS has. The trajectory is clear that if I keep uploading hi-res pictures to the blog it will eventually fill my VPS completely. Not good at all!
I was hesitate move forward with S3 as I don’t want extra spending on already expensive VPS hosting, plus I was expecting the setup to be difficult. However, using this simple guide I was able to set up S3 and CloudFront (available as a separate guide) with relatively little effort. It does require payment, but with how little this blog is using it probably would be very manageable. The same principle applies to many other providers, such as Google Cloud and DigitalOcean Spaces.
It does appear that this combo works out really well, and I am already noticing significant improvement on the image load speed. Hopefully those of you who are in China can also observe similar effects.
That concludes this little update. Stay tuned for future updates 🙂 (not like I have 4 posts worth of backlog but oh well ╮(╯▽╰)╭)
If you find this post helpful, please consider buying me a coffee :)