I am building a web application that allows the user to upload high res images (in the ballpark of 10mb). After its uploaded it creates a medium sized and thumbnail sized image of the upload. It seems it takes upwards of 100mb to of memory allocated to PHP just to resize to the medium image. I don’t have a lot of experience in this type of scalability, will the site easily crash? Will I need webservers with 16gb of memory just to handle the load of the resizing? Are there alternative? Any information would be greatly appreciated!
Thank you!
You could create a queue of images to be resized and ensure that only x number of images are being resized at any given time.
xwould depend on the amount of available memory.If you resize the images in real time as soon as they are uploaded, you are bound to run into a situation where more images are being resized than your memory can hold, which would cause a crash.
Instead, as the image are uploaded, add them to a DB. Then have a PHP script which fetches x images from the DB, forks new processes for each of these images to rezize them. As and when a process report completion to the parent, the parent deletes the image’s entry from the queue and fetches another. Wash, rinse, repeat.