cancel
Showing results for 
Search instead for 
Did you mean: 

Magento2 with cloudfront

Magento2 with cloudfront

Hello Experts, I am setting up Magento 2.4 in AWS and want to run through the architecture with you all if anyone has done similar setup and/or if its possible to setup  magento this way.

 

Existing setup:

ALB => EC2 => RDS

I have a public Load balancer that sends requests to two private EC2 instances using a shared EFS storage (where magento is installed) and using RDS MySQL database. The setup works but we are seeing a major performance issue. The site is super slow and needs performance tuning. To do this, we can introduce an external elasticache and only keep the var & media in efs and everything else on local storage but does that going to help?

 

Proposed Change:

Cloudfront => S3

Cloudfront => ALB => EC2

In this change, I plan to use Cloudfront to server any/all static content. So as soon the request comes to cloudfront it will serve the content from S3 bucket and for all other requests it routes it to ALB. Now questions:

1. I know we can move the pub/static & media to s3, but can the requests be directly served from cloudfront or the static content is still served by nginx redirecting to cloudfront internall?

2. Has anyone implemented similar setup?

2 REPLIES 2

Re: Magento2 with cloudfront

While a Content Delivery Network (CDN) like CloudFront may help to some extent, I do believe that most performance gains can be obtained only by implementing Full Page Cache (FPC) like LiteMage Cache or Varnish to speed up the frontend while using Redis Cache to speed up the backend. 

 

You will also want to audit all the extensions and bloat that is bundled with Magento and stripped them out to reduce bottleneck. 

Re: Magento2 with cloudfront

Hello @ashgoelhot2978 ,

 

I understood your issue. I have done this before.

1. I know we can move the pub/static & media to s3, but can the requests be directly served from CloudFront, or the static content is still served by Nginx redirecting to CloudFront internal?

Ans - Yes! we can directly serve media & pub/static from CloudFront.

 

2. Has anyone implemented a similar setup?

Ans - You can improve your site speed by loading CloudFront through media and static.

           Go to your store

           store->configuration->general->web ->Base URLs

           now change the media and static file location.

 

Hope this will help you!

 

Click kudos and accept it as an answer.

Thank you!