CakePHP
Everything directly related to the CakePHP framework
Related Articles
-
Image saving and processing for high traffic sites
Written on 2012-02-03 06:14:00 in CakePHP,
Viewed 3010 times, 0 CommentsI think everyone has already seen code similar like this: What's wrong with this? Let's assume you have an image library behind the Thumb helper. It will process the image supplied in $image. It will try to create the thumbnail, opening a file if it does not already exist at the destination and start processing the image. Once complete, it will write it out to the - as long as process takes - locked file. The issue with this is the race condition in which another user attempts to load the same page, before the initial image resize and write process has completed. The helper will do exactly as it is told, and attempt to create the image thumbnail as it doesn't yet exist. Consider a very busy site, and you can see that this would quickly bring a server to its knees. This is not as much of a problem when you have just a few visitors per day, or per hour. However, if you ...