Centos – High CPU usage with systemd-journal 219 on CentOS

centosjournaldsystemd

systemd-journal seems to have hig CPU usage, compare to HAProxy that is the actual service on the node:

385   root      20   0   69948  26152  25776 S   3.0  0.2   0:04.05 systemd-journal
22509 haproxy   20   0   58264   7256   1812 S   1.3  0.0   0:00.45 haproxy

CPU:

vendor_id       : GenuineIntel
cpu family      : 6
model           : 63
model name      : Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
stepping        : 2
microcode       : 0x25
cpu MHz         : 2400.139
cache size      : 30720 KB

OS:

Linux ip-172-33-30-32.eu-central-1.compute.internal 3.10.0-514.10.2.el7.x86_64 #1 SMP Fri Mar 3 00:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Systemd:

systemd-219-30.el7_3.7.x86_64
systemd-libs-219-30.el7_3.7.x86_64
systemd-sysv-219-30.el7_3.7.x86_64

Is there a way to optimize systemd-journal to have lower CPU usage? Is this supposed to be normal for logging to use this much CPU?

Best Answer

Firstly, it doesn't seems much of high cpu-usage.

journald, has a more complex workflow than rsyslogd, since it process and keep the data in a more structured form. If you have very high log output to the journaldby your services, it is normal that journaldis overloaded.

In order to optimize journald; Journald has following settings as defaults within following file:

/etc/sysconfig/journald.conf

   #RateLimitInterval=30s
   #RateLimitBurst=1000

If your service logs are non-critical, you can lower the rate limits to suspend the logs of the service which overloads the journald. It also comes with disadvantage that you may lose your logs. Which you will be notifed by journaldstating the suspended log counts within RateLimitInterval, as an enrty instead of logs which are suspended.

Setting does to "0" will disable suspending, and you will have much higher cpu-usage.

If logs are important for you seperate service logs from journald and use rsyslogd. But again this is not high cpu-usage.

Related Topic