Fixing Magento's catalog image difficulties #3627
Replies: 2 comments 10 replies
-
I offset resizing and watermarking to a CDN, I've also modified every project in order not to have different copies of all the images on a per-store bases, which in most cases doesn't make any sense. |
Beta Was this translation helpful? Give feedback.
-
Also on our end, the media folder is always a problem, especially when the theme generates many thumbnails (often unnecessary ones), and the cache folder grows rapidly. I was also looking for a systematic solution to move it out of the nvme, which costs me a lot compared to an S3 bucket. Ideally, it would be to reserve the NVMe disks exclusively for handling dynamic files. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
be me: Merchant adds thousands of new products every year and has a trigger-happy photographer with a 50MP camera.. Disk usage alerts.. Time to upgrade server disks again!
be me: Merchant updates watermark or other image config during peak hours and server gets pummeled trying to suddenly resize thousands of images..
I'm querying to see how much interest there is in a solution to these problems. I'm sure with Magento being as old as it is many of you have already worked around this to some degree but I am looking to fix it fix it and I have an idea to propose.
To me the crux of the problem is that even if you use S3, Magento requires every file to be present on the server, not just the originals but also the resizes, of which there could be many variations and cleaning them up is only simple if your system can handle a sudden wipe of the image cache but they can still take up much space.
Questions:
My proposed solution is to make minimal changes such that the catalog images are not stored on the local disk at all and are only stored in S3. Resized images are handled by a "resizer" service (microservice if you like) which sits behind a caching CDN and generates the resized images on the fly. As long as the cache is effective at maintaining a high hit rate, the resizer service should theoretically not get hit too hard, but it can also be deployed to a serverless environment so you don't have to worry about provisioning large capacity for it.
I've built a proof of concept for this which appears to work great for my specific use case. However, it is not quite ready for general use as it lacks:
The resizer service is written in Node.js using https://github.com/lovell/sharp and is already fairly configurable. The image library is very mature and well-supported and blazing fast with excellent image quality output. As a bonus this allows you to take advantage of webp with zero additional effort as the resizer converts to webp by default (if you wanted to support really old browsers you'd want to change the default). It can be deployed to any serverless environment or just run on the same server for small deployments. It is easy to test with docker-compose by launching minio locally as an S3 stand-in.
I've been improving a fork of https://github.com/thaiphan/magento-s3/ - started 5 years ago! 🤣 If I remember correctly the author is happy to allow OpenMage to absorb this extension into the core but I don't think it would be completely necessary and it could remain a separate extension although without a designated maintainer I think I'd prefer it merged into core.
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions