We need to add a text watermark to an image, using something like imagegettftext. In our case there will be about 30 standard “base” images, and tens of thousands of text watermarks that will need to watermark each base image.
The watermark text is finite, but large (call it 100k total). These represent part numbers / SKUs.
So the question is will we be better off from a perf perspective to pre-generate all of the files, and just let the php code find the appropriate file on the file system (we’d use a common naming convention, ex: baseImage_SKU.png) or we be better off just dynamically generating the images on the fly, rather than searching through the file system.
The third option would be to check if the image exists on disk, and if not generate and persist it for future use with a well known name
These images will be used on php web pages, and average under 5 requests per second during peak load. The server will be a dedicated LAMP stack – built for this application (we can tweak hardware as needed).
General logic says CPU will out perform disk I/O, but I’d love to know what others think, or if anyone has done something similar.
We did some (basic) perf testing. Pre-Generating the files was the best option for us, and since these are small (several k each) disk space was not an issue. We’ll probably optimize by using folders to sort things better once we have more images, but other than that no other optimizations are needed.