I'm on an i7 core but monerod consumes up to 300% CPU at times. When I am catching up on the blockchain, it renders my computer nearly unusable. Is this normal?
When the chain is synced, CPU use is OK.
Monero Stack Exchange is a question and answer site for developers and users of the secure, private and untraceable cryptocurrency Monero. It only takes a minute to sign up.Sign up to join this community
Basically what jwinterm said.
I think your best bet, assuming you want to do something else with your computer while catching up rather than catch up ASAP, would be to add
--prep-blocks-threads 1 (or 2; it defaults to 4) to your command line. This will make it use only one (or two) core(s) to compute POW while in "catch up" mode.
Monerod tries to sync as fast as possible, but the load on a server is so high that monerod slows down the whole server, databases, other websites... I guess that's what most private users want, but not if you are a sysadmin responsible for others too.
--prep-blocks-threads 1 parameter is not the solution as even with less and smaller blocks monerod maxes out virtual memory, boosting CPU usage up over 140% on big dedicated servers. I have had constant loads of 15 on a 16GB RAM 4-core server for over an hour. Only during the time of synchronization of course, which on a good server in a data center only takes like two to three hours, at the max.
In other discussions users point to
cpulimit, nice, renice and ionice commands. At first sight true, but these commands can only handle single programs (with one thread). Monerod on the other side kicks off with up to 12 or 15 threads and cpulimit can't handle that... or only for a short time.
The solution to get monerod sync and run with a restricted, reasonable amount of ressources are the cgroup-tools and cgroup commands. That sounded intimidating when I heard it the first time, but it is actually just 4 lines of code.
As root on your server in the command line install cgroups
apt-get install cgroup-tools
Then create your cgroup
cgcreate -t monero:monero -a monero:monero -g memory,cpu:monerogroup
with monero being the normal username who will eventually run monerod (don't do it as root...). monerogroup is my groupname for this restricted group. You want to set up memory and CPU limitations.
Assign the ressources
cgset -r memory.limit_in_bytes=$((4*1024*1024*1024)) monerogroup cgset -r cpu.shares=128 monerogroup
The first line allows up to 4GB for monerod, the second an eighth of CPU power. The maximum being 1024.
Switch user to normal user (in this case user monero) and run monerod
cgexec -g memory,cpu:monerogroup ./monerod --detach
Feel free to fine tune it and restrict it even more. Add a restriction for the virtual memory as that's the one that gets incredibly blown up.
This is a fantastic way to tame monerod and run it safely and in the long run on your server as I do. Support Monero by running more nodes.