Reputation: 1761
I have big imports, where I need to create for each entry an thumbnail of an image. The problem is, that, when the server is not the fastest one, for each entry I need 1-2 seconds to import it with the thumbnail in the DB. This is a huge time by 200k rows.
Is there any library in PHP where I can start for example the creation of 10-20 thumbnails as threads, parallel in the same time, so I can increase the import 10x, I hope.
Upvotes: 0
Views: 142
Reputation: 9486
Perhaps you should look into increasing the PHP memory limit. More memory may enable PHP to process each image faster. If you have PHP process multiple images simultaneously, they will most likely each be processed more slowly and you will end up with the same or worse overall speed.
Also, why are you storing the images in the DB? Maybe you should instead store them in the filesystem and just store a reference to their location in the DB.
Upvotes: 0
Reputation: 21007
Php provides functions as pcnlt_fork()
but they should be used only from the CLI scripts. There's no way of making your webscript parallel. However you can always execute (for example) bash script which will run imagemagick resize ... &
. But generally better approach is to prepare cronjob which will generate thumbnails in backgroud.
Upvotes: 1