DEV Community

Vuong
Vuong

Posted on • Updated on

Magento multiple instances & resource sharing on AWS

(I just move the old blog from Medium to dev.to)

For handling media images & static contents. We were listing the solutions we have to try. What is the ability or not as the options of a team have no knowledge about AWS services stack.

Requirement:

  • Fast even data size is small
  • Latency is minimal
  • Ability to scale Magento instances
  • Easy to handle, permission file heed

Elastic File System (EFS)

No. Very slow if your website has less than 100 GB of data. The time to warm up cache.

EFS always mentions case study with minimum data size is 100 GB. Many blog posts mention it, they're also warning that you only get the good throughput when you have this minimum data size.

Amazon EFS Performance - Amazon Elastic File System

The related EFS & Magento articles:

  1. AWS EFS, EBS or S3: Comparing Pricing, Performance and More

  2. Magento Multi-Node Implementation on AWS: S3 vs EFS

  3. Integrate Magento 2 with EFS - Cloudkul

  4. (Poor) EFS Performance for Software Builds - DZone Performance

We didn’t believe in these articles about minimum data size, we tried and failed.

In the first case, we're mounting generated/, var/, pub/ with an ambition that we can scale a new instance without warming cache on it. Just provisioning, pull the code, build-and-up our instance.

In the second case, we only mount pub/media, pub/static … (need update)

If you still consider to use with a correct, I hope this post will help you more:

Improving performance when upgrading Magento 2 with Elastic File System

Elastic Block System (EBS)

No. Although, it is faster than EFS but EBS just supports mounting to only one EC2 instance. It doesn’t be flexible for scaling.

Yes. If you wouldn’t like to scaling.

S3 (via AWS SDK — S3 client)

github.com/thaiphan/magento2-s3
Use Amazon S3 as the file storage solution for your Magento 2 application

The concept that we can use the command to syncronize local folder to a specific S3 bucket.

See here: https://github.com/thaiphan/magento2-s3/blob/master/Console/Command/StorageExportCommand.php This author used AWS SDK, more detail, he used \AWS\S3\S3Client interacting with S3 server through HTTP requests.

Another repository support for S3, ability to configure in Admin panel:

https://github.com/flagbit/Magento2-Flysystem

S3 & File Gateway (via mounting fundamental)

S3 but no need handing request by plugins. S3 but use a gateway in a middle.

The tutorial to setting up the File Gateway and uses S3 bucket for storing.

Creating AWS File Gateway as an NFS storage for your EC2 instance

This below video will explain more about the big picture for multiple instances mounting:

Conclusion

S3 is a final one for my team to move forwards on Magento with multiple servers and load balancing. Best for price, good for performance on small project.

I can’t finish this article immediately after my team done the work. So now, just write here for sharing the options and some comments on those after tried them.

Top comments (1)

Collapse
 
vuong profile image
Vuong

Related to EBS, it would be a helpful article n2ws.com/blog/how-to-guides/pre-wa...