Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

How to limit pigz to N processors - workaround for not editing cpbackup

Discussion in 'Workarounds and Optimization' started by freedomizer, Nov 24, 2012.

  1. freedomizer

    freedomizer Member

    Nov 24, 2012
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Root Administrator
    Until WHM releases a new version which works with pigz (multi process/core version of gzip), you can do an in-place replacement for gzip with pigz

    Pigz compresses the same file a lot faster than gzip as it uses all processors. (see other threads)

    However on a production server it is not healthy to run a process with 100% processor usage on all cores as it denies service.

    There is a command line parameter -p n which limits pigz to n processes, howerver to use this you need to mess with Cpanel scripts.

    I found it easier to just edit the pigz source and generally limit to max n processes.

    To make this mod:
    1) download pigz source from official page
    2) unpack in a folder
    3) edit pigz.c (with nano or other editor):
    find this function and put what I highlighted with red (around line 3354):
    (this will check if the number of cores found is greater than 4 and if so will return 4, otherwise will return the real number of cores.

    if you have only 4 cores and wish to limit pigz to use only 2 then:
    4) save the file
    5) run:
    6) replace existing gzip with new pigz:
    cp /bin/gzip /bin/gzip.old
    cp /bin/gunzip /bin/gunzip.old
    cp pigz /bin/gzip
    cp unpigz /bin/gunzip

    this is not a very elegant solution but only a patch until full pigz support will be published by WHM which includes settings to limiting maximum cores to be used for backups.

    generally any process that uses gzip will now be using only the max cores you set and it is rare when you want all cores at full steam on a production server

    hope this helps
    #1 freedomizer, Nov 24, 2012
    Last edited: Nov 24, 2012

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice