Pigz is a parallel implementation of GZip, it compresses using threads to make use of multiple processors and cores.
Install Pigz
You can install easily pigz on your server by running :
apt-get install -y pigz
Using pigz instead of gzip
Then you will be able to use the command pigz
instead of gzip
, but you can also use pigz with the archiving tool tar
.
Usually to compress an archive with gzip, you will use something like that :
tar -cvzf myarchive.tar.gz myfile
It’s not very different with pigz :
tar -I pigz -cvf myarchive.tar.gz myfile
To extract a gzipped archive with pigz, it’s exactly the same process :
tar -I pigz -xvf myarchive.tar.gz
Performance
With Pigz, you can archive a single file of 100MB two times faster than with gzip
# without pigz
root@nginx ~ # time /bin/tar -cvzf 100Mio.dat.tar.gz 100Mio.dat
100Mio.dat
real 0m4.449s
user 0m4.236s
sys 0m0.364s
# with pigz
root@nginx ~ # time /bin/tar -I pigz -cvf 100Mio.dat.tar.gz 100Mio.dat
100Mio.dat
real 0m2.261s
user 0m4.140s
sys 0m0.248s