Run PHP asynchronously in own threads
When you start a php script it will wait until it is done. Lately I and my customers were facing a huge problem where pictures were uploaded to a gallery web app and the problem was in the thumbnail generation.
The thumbnails were generated as someone opened the gallery (frontend). This resulted in long loading page and sometimes strange errors. Sometimes the page didnt load at all because Apache was working heavily on the thumbnails. Even worse was that the gallery was visited by many people simultaneously. The gallery app created 4 thumbnails out of one image in different sizes.
There are better ways to handle this. I could generate the thumbnails in the backend and show the thumbs on the frontend when they were generated. The problem is that I am using Owncloud as the backend and it is a pain the ass to extend Owncloud… but thats another story.
So, how did I manage to get rid of the problem and make the thumbnail generation fast and non blocking?