Linux Kernal Logging makes system slow

1st December 2026

Why
UFW loggs to the console, which is a bottleneck

How to Fix It
To prevent this from happening, you need to decouple kernel logging from synchronous console printing.

  1. Rate-Limit UFW/IPTables Logging (Immediate Fix)If you must log packets, strictly limit how fast the kernel can write them.Modify your underlying iptables rules used by UFW to include a limit match:bash-A UFW-BLOCK -m limit –limit 3/min –limit-burst 10 -j LOG –log-prefix “[UFW BLOCK] “
    Use code with caution.
  2. Disable Console Logging for Packet DropsAvoid printing noisy packet logs to the physical or graphical console (/dev/console). They should only go to system logs (like journald or /var/log/kern.log).Lower your console log level so informational packet logs don’t hit the screen:bashsysctl -w kernel.printk=”3 4 1 3″
    Use code with caution.(This keeps critical errors on the console but filters out standard informational/warning logs).
  3. Enable Asynchronous printk (Kernel-Level Fix)Modern Linux kernels offer a way to offload printk writing to a dedicated background kernel thread, preventing the CPU handling the event from locking up.Pass printk.synchronous=0 as a kernel boot parameter (on supported kernels), or ensure CONFIG_PRINTK_INDEX and asynchronous printk features are enabled in your kernel configuration.

Running sysctl -w kernel.printk=”3 4 1 3″ does not require a restart.

How to make it permanent
echo “kernel.printk = 3 4 1 3” | sudo tee /etc/sysctl.d/10-console-messages.conf
sudo sysctl -p /etc/sysctl.d/10-console-messages.conf