Schogini - Amazon AWS, Magento and Mobile Developers
 

Use Case: Magento 2 EE AWS CloudFront CDN Setup on EC2 Cluster

Requirement

Implementation of Amazon AWS CDN called CloudFront to distribute static and media files for a clustered (load balanced and auto-scaling) Magento 2 Enterprise Edition installation. Correct synchronization of the newly generated static files and newly added or updated product images etc. was a prerequisite.

Challenges

  • Correct CloudFront’s “Origin” setting
  • Selective invalidations so that the content gets freshly picked up
  • Cross-origin resource sharing (CORS) error prevention for the frontend users
  • CDN should only be applied to the frontend, admin should be CDN free

Solution

The solution that Schogini implemented has these elements:

  • Pre-generation of all thumbnails via a custom backend script written for M2EE by Schogini team. This ensured that any catalog product updates resulted in immediate creation of pub/media/catalog/product/cache files. eg: All the cache files in these folder were auto populated.

      100x100
      140x140
      152x188
      75x75
      75x90
      76x76
      78x78
      90x90
      image
      small_image
      swatch_image
      swatch_thumb
      thumbnail
      
  • AWS CLI based custom Bash script to invalidate origins

  • Allow Origin Setting Adjusted

  • CloudFront Origin pointed to an exclusive S3 Bucket

Results

Author

Sree - Founder/MD/Chief Cloud & DevOps Architect
Sree is an evangelist and thought leader in the Continuous Delivery and DevOps space. In addition to being a Cloud Architect, he also imparts training in AWS, Docker and other DevOps related technologies. Sree's core speciality is in building scripted, version-able, repeatable, auto-scaling, load-balanced and self-healing infrastructures. Sree also works in server-less architectures using AWS Lambda service and Internet of Things (IOT). Sree is also an Amazon Certified AWS Cloud Architect with 15+ years of server experience. He is also the author of Docker Fundamentals [Integrated Course] published by Packtpub.
Know more about the author.
 
 
 

CONTACT US

We love to talk to you, all enquires are replied to in under 4 hours.