Page 1 of 1

Imagick and threads

Posted: 2011-09-29T10:12:02-07:00
by Prosperent
First some background. We resize about 50 million source images into 5 different sizes. For this we use a cluster of 16 dual 8 core servers. We don't have imagemagick installed on any of the servers, but rather just imagick through the yum pecl package (yum install php-pecl-imagick). This works fine for us, but each process uses several cpu cores which is a problem because of the level of concurrency we push through the system. I've seen the threads about disabling openMP, but that appears to apply to imagemagick and not php-pecl-imagick. Is there anything I can do to disable threading or set the threads to one with the imagick pecl package?

Re: Imagick and threads

Posted: 2011-09-29T10:39:21-07:00
by Prosperent
I found /usr/lib64/ImageMagick-6.6.5/config which has the policy file and such. Does the pecl package just bundle the ImageMagick library with it? Would be my guess since I can't issue convert -version at the command line. So, is there a way to recompile the version that it installs with the pecl package, or is there a way at runtime to change to one thread instead of what it appears to have defaulted to (16)

Re: Imagick and threads

Posted: 2011-09-29T11:02:33-07:00
by magick
Try adding
  • <policy domain="resource" name="thread" value="1"/>
to your policy.xml file. That sets the maximum threads to 1 site-wide. Alternatively you can set the MAGICK_THREAD_LIMIT environment variable to set the maximum number of threads for a particular ImageMagick script.

Re: Imagick and threads

Posted: 2011-10-06T10:04:46-07:00
by Prosperent
Wanted to come back and update. We pushed this change and the resulting server load decrease was dramatic. We went from a cluster wide average load of 40 to an average load of 4. We can literally get rid of half of our servers after this single change. Our image processing tasks used to spike to 300-500 percent cpu usage per process, and now they are almost always less than 10.