I'm working on a project that requires using various sizes of user pictures at different sections on the site. The images to be served are thumbnails of the main images in various sizes like 35 x 35 pixels, 50 x 50 pixels and 100 x 100 pixels. I want to allow the user upload only one picture.
I am using PHP and Apache as webserver. The site is estimated to get about 400k visits initially and could go up significantly. My question is:
Should I resize the picture to all the various sizes I need, while keeping the original when uploading? or Should I resize the picture only on demand and display (Using something similar to phpThumb ) ?
Please I would like to know which is better performance or speed wise and resource management wise, considering the level of traffic and there could be as much as 100 concurrent users on the site at a given time.
Disk is cheap and resizing on demand is very expensive. I'd never resize on demand for every request. I think you have two options:
Update: nginx has a nice module for resizing on the fly. I'd never use it in production by itself, but if you couple it with a reverse proxy, you'll essentially get the second option without having to write any code.