Is it possible to control cpu usage?
Is it possible to control cpu usage?
I checked the cpu usage. It is reaches 100% with some convert scripts. Memory is free. But CPU usage become full.
Can we control the CPU usage?
Thanks
Can we control the CPU usage?
Thanks
Re: Is it possible to control cpu usage?
CPU should be 100% otherwise its idle and not working. However, to reduce CPU usage, set the throttle resource policy in policy.xml or set the MAGICK_THROTTLE environment variable. See http://www.imagemagick.org/script/resou ... nvironment.
Re: Is it possible to control cpu usage?
i read that link. But I am not sure how to change the environment variable.
Can you guide me how to do it?
I am using centos.
Can you guide me how to do it?
I am using centos.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Is it possible to control cpu usage?
Environment variables are just set of sting variables that are passed from parent programs to children
To set it for just one command put it before the command...
The number is in milli-seconds and it means go to sleep this long at selected (convenient) points in the programs image processing to allow other programs to run.
However 100% usage should not be a problem. Other programs at an equal 'nice' level should also run.
Usually the worse problem is the use of multiple threads on a mutli-core processor. You can turn of multi-threading using...
or more permanently set the variable using
You can list environment variables using the command env
For more on thread problems see IM Examples, Making IM Faster (in general)
http://www.imagemagick.org/Usage/api/#speed
To set it for just one command put it before the command...
Code: Select all
MAGICK_THROTTLE=50 convert ...
However 100% usage should not be a problem. Other programs at an equal 'nice' level should also run.
Usually the worse problem is the use of multiple threads on a mutli-core processor. You can turn of multi-threading using...
Code: Select all
MAGICK_THREAD_LIMIT=1 convert ....
Code: Select all
export MAGICK_THREAD_LIMIT=1
For more on thread problems see IM Examples, Making IM Faster (in general)
http://www.imagemagick.org/Usage/api/#speed
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Is it possible to control cpu usage?
/var/log/message is giving me the following warning
I hired a freelance to fix this problem.
But he is telling that convert command is using higher cpu usage.
The website is hardly running. It took very long time to load.
Top command gives something like this.
I have already added
Code: Select all
kernel: possible SYN flooding on port 80. Sending cookies.
But he is telling that convert command is using higher cpu usage.
The website is hardly running. It took very long time to load.
Top command gives something like this.
Code: Select all
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
10939 apache 20 0 204m 5824 2452 R 201.3 0.1 0:06.06 convert
10947 apache 20 0 135m 3828 2016 R 51.5 0.0 0:01.55 convert
10955 apache 20 0 198m 6064 2020 R 43.5 0.1 0:01.31 convert
10972 apache 20 0 198m 3732 2016 R 4.6 0.0 0:00.14 convert
Code: Select all
export MAGICK_THREAD_LIMIT=1
Re: Is it possible to control cpu usage?
To reduce the load ImageMagick puts on a server you can single thread it by building without OpenMP support or as you did, or limit the number of threads to 1 or 2. You can do this with the policy.xml configuration file, for example,
There is typically more overhead when using ImageMagick from the command-line. Instead use it from a scripting language, Perl or PHP, for example.
We have an ImageMagick web site @ http://www.imagemagick.org/MagickStudio/ that has supported thousands of image manipulations each day and the host computer is never overwhelmed. You can download the source @ http://www.imagemagick.org/download/per ... 9.3.tar.gz and see the sorts of things we do to ensure our host server runs efficiently.
- <policy domain="resource" name="thread" value="2"/>
<policy domain="resource" name="throttle" value="1"/>
There is typically more overhead when using ImageMagick from the command-line. Instead use it from a scripting language, Perl or PHP, for example.
We have an ImageMagick web site @ http://www.imagemagick.org/MagickStudio/ that has supported thousands of image manipulations each day and the host computer is never overwhelmed. You can download the source @ http://www.imagemagick.org/download/per ... 9.3.tar.gz and see the sorts of things we do to ensure our host server runs efficiently.
Re: Is it possible to control cpu usage?
I have downloaded and going to check it out.
Memory is not much used.
Only CPU is used a lot.
But i am quite confused whether it is an attack or overload which slows down the site.
Where is policy.xml file located?
/usr/bin/convert is the convert path on my computer
Memory is not much used.
Only CPU is used a lot.
But i am quite confused whether it is an attack or overload which slows down the site.
Where is policy.xml file located?
/usr/bin/convert is the convert path on my computer
Re: Is it possible to control cpu usage?
Also, I am using exec to process images with imagemagick.
How do i use PHP module? Do i need to install anything?
Will everything work in the same way as it is working in exec?
How do i use PHP module? Do i need to install anything?
Will everything work in the same way as it is working in exec?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Is it possible to control cpu usage?
I believe that exec is a PHP command, so you are likely already using PHP, but it essentially is just an interface to the command line. But Magick was suggesting that you use something like Perlmagick or MagickWand for PHP or Imagick. See the various IM APIs at http://www.imagemagick.org/script/api.php
Re: Is it possible to control cpu usage?
Using exec and imagic differs in performance?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Is it possible to control cpu usage?
User Bonzo and I did some limited timing tests for command line, PHP exec and Imagick and did not find that much difference. However, I suspect that Perlmagick may be different and faster.
Our timing tests are at:
viewtopic.php?f=4&t=16779
Our timing tests are at:
viewtopic.php?f=4&t=16779
Re: Is it possible to control cpu usage?
You have done nice work!!!
from this page -- http://www.imagemagick.org/Usage/text/
Will it use more cpu memory than the following?
I just am asking because the first one is not using any size.
Code: Select all
convert -font Ravie -pointsize 72 label:'Get Wet!' -border 10 \
-tile tile_aqua.jpg -draw "color 0,0 reset" \
-tile tile_water.jpg -gravity center -annotate +0+0 'Get Wet!' \
autosize_wet.jpg
Will it use more cpu memory than the following?
Code: Select all
convert -size 800x120 xc:black -font Corsiva -pointsize 100 \
-tile tile_disks.jpg -annotate +20+80 'Psychedelic!' \
-trim +repage -bordercolor black -border 10 funfont_groovy.jpg
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Is it possible to control cpu usage?
label: creates its own size image to match the pointsize and have no extra space around it. see http://www.imagemagick.org/Usage/text/#label
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Is it possible to control cpu usage?
The first uses label to create a canvas of about the right size. This is then cleared (tiled) and the font again re-drawn using -annotate so that we can use a tiling fill.
The other method is to just create a label using black and white only. Then use that as a composite mask operator to select different background foreground tile patterns. See... Coloring a Gray-scale Text Image
http://www.imagemagick.org/Usage/text/#coloring_text
and the sections this links to.
The other method is to just create a label using black and white only. Then use that as a composite mask operator to select different background foreground tile patterns. See... Coloring a Gray-scale Text Image
http://www.imagemagick.org/Usage/text/#coloring_text
and the sections this links to.
There are lots of ways to skin a cat, and what method you use depends
on what you want that skin for, and how messy you like the results!
-- Anthony Thyssen
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/