Syncthing is a software that allows file synchronization. It is especially through for road warriors as it handles two endpoints behind a NAT through its relay server. However, if you are like me with more than 600 GB of data to have synced between your personal laptop and desktop, and you modify files frequently, you will find that syncthing needs a lot of CPU to work.

As I see, syncing is a background task. I am not usually on both computers at the same time. So, as it is not a real-time critical task, it does not matter if files are not updated right away. I figured out a way to fix this issue. In short terms, the use of cpulimit. I have already written about how to limit the CPU use in general. I will explain how I did with syncthing, since in Mageia 6, syncthing is a service and systemd is used.

Dealing with Systemd

Syncthing unit definition file synctinog@.service has the following definition:


ExecStart=/usr/bin/ ${GUI_ADDRESS}


The ExecStart line points to a file which it is there where the cpulimit s called. It has the following content:

if [ -x /usr/bin/cpulimit ]; then
/usr/bin/cpulimit -l 50 /usr/bin/syncthing -gui-address=$1
/usr/bin/syncthing -gui-address=$1

This script will look for cpulimit in a specific route where Mageia 6 installs it. If the file exists and it is executable, it will use it, otherwise, it will call syncthing as usual. Please note that a 50% CPU utilization is hardcoded here. I don't see any reason why syncthing should use more than that.


blog comments powered by Disqus