I have a systemctl service that generates rather high volume of logs, on the order of 20-50 Gb per day. The service runs on a VPS with Ubuntu 24.04 LTS. The service is written in node.js, and simply console.logs log messages. As it is running as a systemd service, these logs are picked by journald, and I can then view and analyze them using journalctl.
From time to time I observe the following problems:
The logs in journalctl are severly delayed. Namely, the service logs current time every minute, and in
journalctloutput I see records such asJul 07 18:29:43 vc start-manager.sh[2733323]: Current time: 2025-07-07 18:24:43The first timestamp comes from journalctl, the second comes from the service; the difference can be up to 20 minutes and more
systemd-journaldprocess eats 20-40% CPU as reported by htopThe node.js service gradually increases its heap size (as reported by node.js's
process.memoryUsage()), until it runs out of heap and crashes.I've dumped node.js heap and saw that almost all memory is eaten by log strings (that actually should be immediately written to stdout).
So my assumption is that journald can not manage such a large flow of logs, the stdout pipe from the service to journald becomes full, and nodejs apparently starts bufferizing log messages. This explains both high heap usage and log delays.
Overall, when this happens, the system doesn't look overloaded: la15 is around 3 (with 8 vcpu), memory usage is around 2-5 Gb out of 16 Gb, and disk write is around 5 MBytes/s (almost all by systemd-journald), which does not sound too much (sync; dd if=/dev/zero of=tempfile bs=1M count=1024; sync reports 600-700 MB/s).
There are also periods when everything works fine, logs are not delayed, systemd-journald consumes much less CPU, and node.js service does not use too much heap. I do not see much difference between these two regimes; in particular, the log speed by the service is approximately the same.
My journald config (in /etc/systemd/journald.conf.d/journald.conf) is
[Journal] SystemMaxUse=100G SystemKeepFree=30G SystemMaxFileSize=1G SystemMaxFiles=100 RateLimitInterval=0 RateLimitBurst=0 How can I diagnose and fix this behavior? Or am I hitting inherent journald performance?
STDERR, opening a file, ... )journaldfeatures are you using? Can you just usersyslogdirectly and pitchjournaldoverboard? See How can journald be disabled?--sinceoption that allows to quickly browse logs around given point in time. In fact, I did not intentionally choose journald, I'm using it simply because it is default; and now that I encountered problems I'm asking what are the reasons, and the answer "journald is a wrong tool" is a completely valid answer...