An important part of selling stuff online is product visualization - allowing a shopper to see the product. A common component of product visualization is showing a product in all available colors. For example, if a t-shirt can be made in black or white, it’s important to show an image of each color option so that a shopper can see whether the shirt design looks good over both colors.
I had a project recently where there was a need to visualize lots of products in dozens of colors. There were too many combinations of product and color to create all the necessary images by hand, so an automatic coloring solution was created that used Little CMS to apply color transforms expressed as ICC profiles. The solution worked but it needed to be scaled up to be able to color all the product images in a reasonable amount of time.
Migrating to Azure Batch
To scale up the coloring solution (let’s call it the Colorizer), I initially tried running it in an Azure function. However the memory limit on the Consumption plan is 1.5 GB, and the Colorizer used more than that since the product images were very large. Also I didn’t want to use the App Service plan because the function didn’t need to be always on, and the Premium plan hadn’t been released yet.
Instead of Azure functions, I decided to use Azure Batch. Batch seemed like a perfect fit because it supports running large parallel jobs on demand. Here is a short summary of a Batch workflow:
Create a pool, which is essentially a group of VMs
Create a job, which is a collection of tasks that run on a pool
Add tasks to the job, which Batch will distribute across the available VMs in the pool and run