In the process of using DirectAdmin, you will find that the backup process of DirectAdmin is not very fast and in this article, AZDIGI will show you how to speed up the backup process of DirectAdmin with PIGZ . This slowness is because, in DirectAdmin’s backup process, data compression takes up most of the time, and with the default compressor, Gzip only uses 1 CPU cores but PIGZ can be used CPU cores that the server has.
Note: If your VPS/server has only 1 CPU core, it will not improve the speed.
What is PIGZ?
PIGZ stands for “parallel implementation of gzip”. PIGZ has a similar compression function to Gzip, but Gzip only uses 1 core, while PIGZ uses many cores and many processors simultaneously. Significantly reduces data compression time. PIGZ is written by Mark Adle and uses the zlib and pthread libraries.
Speed up DirectAdmin backups with PIGZ
To speed up the backup process of DirectAdmin with PIGZ, we perform the following 2 steps.
Step 1: SSH into your DirectAdmin system
To integrate PIGZ into your DirectAdmin VPS/server, we need SSH with root privileges first. If you do not know how to SSH into your VPS/Server, you can refer to the following tutorial:
After successfully SSHing, we continue with step 2 to install PIGZ.
Step 2: Install PIGZ with CustomBuild 2.0
First, we need to make sure we are using CustomBuild 2.0 on our DirectAdmin system. To check the CustomBuild version, please check out the article below:
If your CustomBuild version is lower than 2.0, you need to upgrade CustomBuild 1.x to 2.0, you can check out the following tutorial:
To integrate PIGZ into DirectAdmin, we just need to execute the following 3 commands:
cd /usr/local/directadmin/custombuild ./build update ./build pigz
Explanation of the above commands:
- Command 1: Move to the custombuild folder
- Command 2: Execute the command to check the current version and the latest released version
- Command 3: Install PIGZ into DirectAdmin
The installation process is speedy and as shown below after the installation is complete.
Because my VPS has 4 CPU cores, PIGZ will use 4 CPU cores. If you have more CPU cores, then the number will be different. You can now speed up DirectAdmin backups with PIGZ complete. You can continue reading this article to get other helpful information about PIGZ.
4. Change the number of CPU cores PIGZ can use
Because when installing PIGZ will automatically set the number of usable CPU cores equal to the total number of CPU cores of your VPS/Server. So once the backup takes place, the CPU/Load Average will increase, sometimes slowing down the services on the VPS/Server. Even at the user level, using Backup on their DirectAdmin interface will, by default, use PIGZ to compress data. So it is best to reduce the number of CPU cores PIGZ can be reused so that the VPS/Server is not overloaded.
To change this parameter, we just need to modify the configuration of DirectAdmin with the following command:
/usr/local/directadmin/directadmin set pigz X
Remember to replace X with the maximum number of CPU cores that PIGZ is allowed to use.
With my VPS, I adjusted it to 3 with the command
/usr/local/directadmin/directadmin set pigz 3, below is the image after I run this command.
So we have reduced the CPU usage of PIGZ complete. You need to restart DirectAdmin to receive the new configuration. The command to restart DirectAdmin with all operating systems is as follows:
echo "action=directadmin&value=restart" >> /usr/local/directadmin/data/task.queue.cb /usr/local/directadmin/dataskq d20 --custombuild
5. Use PIGZ in other common decompression operations
If you want to take advantage of PIGZ to compress other data we can use the following commands.
To compress a directory or a file, use the command:
tar cf - TEN_DOI_TUONG | pigz > TEN_DOI_TUONG.tar.gz
Remember to change TEN_DOI_TUONG to the object you need to compress.
To decompress, use the following command:
The use of PIGZ in the decompression process also greatly reduces the decompression time.
If you are interested in other commands, you can refer to the following detailed article:
Thus, we have completed the steps to speed up the backup process of DirectAdmin with PIGZ as well as the notes when using PIGZ. Hope you like this article, if you find it interesting and useful, please share it widely.
Wishing you success.
If you need assistance, you can contact support in the ways below: