{"id":5107,"date":"2026-11-06T06:05:27","date_gmt":"2026-11-06T00:35:27","guid":{"rendered":"https:\/\/cpanelfree.com\/blog\/linux-out-of-memory-oom-killer-tuning-how-to-protect-mysql-and-web-servers-with-oomscoreadj\/"},"modified":"2026-11-06T06:05:27","modified_gmt":"2026-11-06T00:35:27","slug":"linux-out-of-memory-oom-killer-tuning-how-to-protect-mysql-and-web-servers-with-oomscoreadj","status":"publish","type":"post","link":"https:\/\/cpanelfree.com\/blog\/linux-out-of-memory-oom-killer-tuning-how-to-protect-mysql-and-web-servers-with-oomscoreadj\/","title":{"rendered":"Linux Out-of-Memory (OOM) Killer Tuning: How to Protect MySQL and Web Servers with oom_score_adj"},"content":{"rendered":"<p>Few events trigger more widespread outages in high-traffic web environments than an abrupt database crash caused by the Linux kernel Out-of-Memory (OOM) Killer. Under heavy concurrent query spikes or memory pressure from web workers, the kernel&#8217;s memory management subsystem evaluates running processes and ruthlessly invokes <code>SIGKILL<\/code> against the largest memory consumer\u2014which is almost always your relational database engine. Whether you are staging microservices on <a href=\"https:\/\/cpanelfree.com\">CpanelFree<\/a> or orchestrating mission-critical bare-metal database instances, properly configuring <code>oom_score_adj<\/code> alongside virtual memory sysctl policies is required to prevent catastrophic database downtime.<\/p>\n<p><!-- more --><\/p>\n<h2 style=\"color:#001b41;font-size:24px;font-weight:700;margin-top:36px;margin-bottom:16px\">How to Protect MySQL from OOM Killer Linux Environments: Step-by-Step Architecture<\/h2>\n<div style=\"background:#f9f9f9;border-left:4px solid #001b41;padding:16px 20px;margin:20px 0;border-radius:4px\">\n<p style=\"margin:0;font-size:15px;line-height:1.6;color:#333\"><strong>Direct Answer:<\/strong> To protect MySQL from OOM killer Linux disruptions, set <code>OOMScoreAdjust=-1000<\/code> in a systemd unit drop-in override (<code>\/etc\/systemd\/system\/mysql.service.d\/override.conf<\/code>). This grants total immunity from kernel termination. Pair this setting with strict cgroups v2 memory boundaries, conservative virtual memory overcommit (<code>vm.overcommit_memory = 2<\/code>), and dedicated swap space to guarantee rock-solid database availability.<\/p>\n<\/div>\n<p>The Linux kernel&#8217;s Out-of-Memory subsystem is an emergency safety mechanism designed to save the operating system from a hard freeze when physical RAM and configured swap space are completely exhausted. However, in production web hosting and database environments, its default heuristic algorithm frequently causes severe data corruption, abrupt transaction rollbacks, and lengthy InnoDB crash recovery cycles when it indiscriminately kills <code>mysqld<\/code>, <code>mariadbd<\/code>, or web server daemons instead of shedding transient, non-critical worker processes.<\/p>\n<h3 style=\"color:#001b41;font-size:20px;font-weight:700;margin-top:28px;margin-bottom:12px\">The Core Mechanics of Linux OOM Scoring: Badness Heuristics<\/h3>\n<p>When the kernel memory allocator reaches a critical watermark and cannot reclaim pages through standard buffer eviction, page cache dropping, or swap paging, it invokes the function <code>out_of_memory()<\/code> within the kernel source tree (<code>mm\/oom_kill.c<\/code>). The kernel iterates across all active process descriptors in the system to calculate an integer badness score ranging from <code>0<\/code> to <code>1000<\/code> for each task. The process with the highest calculated badness score is selected as the victim and terminated immediately via an uncatchable <code>SIGKILL<\/code> signal.<\/p>\n<p>The raw badness heuristic evaluates several key parameters:<\/p>\n<ul style=\"color:#444;line-height:1.7;margin-left:20px\">\n<li><strong>Resident Set Size (RSS):<\/strong> The physical RAM consumed by the process&#8217;s anonymous pages and private mappings. Since MySQL allocates large InnoDB buffer pools (often 70% to 80% of total host RAM), it naturally presents the highest raw RSS footprint on the server.<\/li>\n<li><strong>Page Table Entries (nr_ptes):<\/strong> The architectural overhead of virtual memory mapping structures allocated for the process.<\/li>\n<li><strong>Swap Consumption:<\/strong> The number of anonymous swap entries utilized by the process descriptor.<\/li>\n<li><strong>Privilege Modifiers:<\/strong> Root processes traditionally received modest dampening, but modern kernels rely predominantly on explicit score adjustment interfaces.<\/li>\n<\/ul>\n<p>To inspect the real-time OOM badness score calculated by the kernel for any given process, you can read the <code>oom_score<\/code> file inside the virtual proc filesystem:<\/p>\n<pre class=\"wp-block-code\" style=\"background:#f3f3f3;color:#333;padding:16px;border-left:4px solid #001b41;font-family:monospace;font-size:13px\"><code># Identify the PID of your MySQL daemon\nMYSQL_PID=$(pgrep -f mysqld | head -n 1)\n\n# Inspect current badness score (0 to 1000)\ncat \/proc\/${MYSQL_PID}\/oom_score\n\n# Inspect active adjustment offset (-1000 to 1000)\ncat \/proc\/${MYSQL_PID}\/oom_score_adj<\/code><\/pre>\n<blockquote class=\"wp-block-quote\" style=\"background:#f9f9f9;border-left:4px solid #001b41;padding:16px 20px;margin:24px 0\">\n<p><strong style=\"color:#001b41\">Architecture Note:<\/strong> Never confuse the legacy <code>\/proc\/[pid]\/oom_adj<\/code> interface with the modern <code>\/proc\/[pid]\/oom_score_adj<\/code> control. The legacy <code>oom_adj<\/code> scale ranged from -17 to +15 and scaled exponentially. Modern Linux kernels (kernels 2.6.36 through 6.x) standardize on <code>oom_score_adj<\/code>, which provides a linear -1000 to +1000 adjustment mapped directly against the 1000-point badness scale.<\/p>\n<\/blockquote>\n<h2 style=\"color:#001b41;font-size:24px;font-weight:700;margin-top:36px;margin-bottom:16px\">Comparative Architecture Matrix: Default vs. Tuned Production Systems<\/h2>\n<p>Default Linux kernel memory allocations prioritize operating system survival over application integrity. In contrast, an enterprise-tuned deployment implements tiered memory hierarchies, proactive process shielding, and deterministic eviction policies to protect MySQL from OOM killer Linux terminations.<\/p>\n<figure class=\"wp-block-table is-style-regular\">\n<table style=\"width:100%;border-collapse:collapse;margin:24px 0;font-size:15px;text-align:left\">\n<thead style=\"background:#001b41;color:#ffffff\">\n<tr>\n<th style=\"padding:12px 16px;border-bottom:2px solid #001b41\">Feature \/ Metric<\/th>\n<th style=\"padding:12px 16px;border-bottom:2px solid #001b41\">Standard \/ Default<\/th>\n<th style=\"padding:12px 16px;border-bottom:2px solid #001b41\">Tuned \/ Production<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">MySQL oom_score_adj<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">0 (Subject to instant SIGKILL)<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7;color:#20B038;font-weight:600\">-1000 (Complete OOM Immunity)<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">Web Worker oom_score_adj<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">0 (Equal victim weight)<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7;color:#20B038;font-weight:600\">+300 to +500 (Preferred sacrificial tier)<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">Memory Overcommit Policy<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">vm.overcommit_memory = 0 (Heuristic overcommit)<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7;color:#20B038;font-weight:600\">vm.overcommit_memory = 2 (Strict allocation limit)<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">Kernel Min Free Watermark<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">vm.min_free_kbytes ~ 64MB &#8211; 128MB<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7;color:#20B038;font-weight:600\">512MB &#8211; 1024MB (Prevents direct reclaim stall)<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">Crash Recovery Latency<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">15 to 45 minutes InnoDB roll-forward<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7;color:#20B038;font-weight:600\">0 seconds (Database service never killed)<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">Latency \/ Overhead<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7\">Baseline<\/td>\n<td style=\"padding:12px 16px;border-bottom:1px solid #e7e7e7;color:#20B038;font-weight:600\">Optimal<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<h2 style=\"color:#001b41;font-size:24px;font-weight:700;margin-top:36px;margin-bottom:16px\">Production Step 1: Shielding MySQL via Systemd Drop-in Overrides<\/h2>\n<p>Modern Linux distributions running systemd (Ubuntu, Debian, RHEL, AlmaLinux, Rocky Linux) manage process execution trees through cgroups. Manually writing values to <code>\/proc\/[pid]\/oom_score_adj<\/code> via shell scripts is fragile because process IDs change upon restart. The standardized, persistent method is defining <code>OOMScoreAdjust<\/code> inside a systemd drop-in configuration.<\/p>\n<p>When you set <code>OOMScoreAdjust=-1000<\/code>, systemd writes <code>-1000<\/code> to <code>\/proc\/$PID\/oom_score_adj<\/code> upon executing the binary, setting the badness calculation to <code>OOM_SCORE_ADJ_MIN<\/code>. This completely excludes the process from the kernel&#8217;s candidate list during an out-of-memory event.<\/p>\n<p>Create the systemd drop-in override directory and configuration file for MySQL or MariaDB:<\/p>\n<pre class=\"wp-block-code\" style=\"background:#f3f3f3;color:#333;padding:16px;border-left:4px solid #001b41;font-family:monospace;font-size:13px\"><code># File path: \/etc\/systemd\/system\/mysql.service.d\/override.conf\n# (For MariaDB use: \/etc\/systemd\/system\/mariadb.service.d\/override.conf)\n\n[Service]\n# Maximum OOM protection: completely immune to kernel OOM kills\nOOMScoreAdjust=-1000\n\n# Guarantee systemd restart behavior if an external panic occurs\nRestart=always\nRestartSec=5s\n\n# Prevent process killing during system shutdown timeouts\nTimeoutStopSec=300\n\n# Reserve physical memory guarantees under cgroups v2\nMemoryMin=4G\nMemoryLow=6G<\/code><\/pre>\n<p>Apply the unit file modifications and restart the database service safely:<\/p>\n<pre class=\"wp-block-code\" style=\"background:#f3f3f3;color:#333;padding:16px;border-left:4px solid #001b41;font-family:monospace;font-size:13px\"><code># Reload systemd manager configuration\nsystemctl daemon-reload\n\n# Restart MySQL service to instantiate cgroup parameters\nsystemctl restart mysql\n\n# Verify that the kernel has registered the -1000 adjustment\ncat \/proc\/$(pgrep -f mysqld | head -n 1)\/oom_score_adj\n# Output should return: -1000\n\n# Inspect the final computed oom_score\ncat \/proc\/$(pgrep -f mysqld | head -n 1)\/oom_score\n# Output should return: 0<\/code><\/pre>\n<h2 style=\"color:#001b41;font-size:24px;font-weight:700;margin-top:36px;margin-bottom:16px\">Production Step 2: Configuring Web Server &amp; Worker Sacrificial Tiers<\/h2>\n<p>Immunizing MySQL solves only half of the architectural problem. If physical memory is completely exhausted and the Linux kernel cannot terminate MySQL, it must have designated, low-impact processes that it can safely terminate to relieve memory pressure. If every process is set to <code>-1000<\/code>, the kernel experiences an unresolvable memory allocation failure, culminating in a catastrophic system-wide kernel panic (<code>panic_on_oom<\/code>).<\/p>\n<p>The correct enterprise architecture designates web application workers\u2014such as PHP-FPM, Python Gunicorn, Node.js cluster processes, and background worker queues\u2014as sacrificial processes. Web workers can be re-spawned within milliseconds by process managers with minimal client disruption, unlike a database engine that requires crash recovery.<\/p>\n<h3 style=\"color:#001b41;font-size:20px;font-weight:700;margin-top:28px;margin-bottom:12px\">Configuring NGINX and Reverse Proxies<\/h3>\n<p>The reverse proxy layer should be shielded from OOM termination so that active TCP sessions and HTTP\/2 multiplexed streams remain connected even while backend application workers recycle:<\/p>\n<pre class=\"wp-block-code\" style=\"background:#f3f3f3;color:#333;padding:16px;border-left:4px solid #001b41;font-family:monospace;font-size:13px\"><code># File path: \/etc\/systemd\/system\/nginx.service.d\/override.conf\n[Service]\n# Shield master reverse proxy from casual eviction\nOOMScoreAdjust=-500\nRestart=always\nRestartSec=3s<\/code><\/pre>\n<h3 style=\"color:#001b41;font-size:20px;font-weight:700;margin-top:28px;margin-bottom:12px\">Configuring Sacrificial PHP-FPM Worker Pools<\/h3>\n<p>Configure PHP-FPM or asynchronous workers with an elevated positive <code>OOMScoreAdjust<\/code> value so the kernel will always harvest them first when physical memory thresholds are breached:<\/p>\n<pre class=\"wp-block-code\" style=\"background:#f3f3f3;color:#333;padding:16px;border-left:4px solid #001b41;font-family:monospace;font-size:13px\"><code># File path: \/etc\/systemd\/system\/php8.3-fpm.service.d\/override.conf\n[Service]\n# Prioritize worker pool for OOM reaping under extreme memory pressure\nOOMScoreAdjust=300\n\n# Ensure master daemon automatically restarts terminated children\nRestart=always\nRestartSec=2s<\/code><\/pre>\n<blockquote class=\"wp-block-quote\" style=\"background:#f9f9f9;border-left:4px solid #001b41;padding:16px 20px;margin:24px 0\">\n<p><strong style=\"color:#001b41\">Architecture Note:<\/strong> When PHP-FPM workers are sacrificed, users may receive an isolated <code>502 Bad Gateway<\/code> or <code>504 Gateway Timeout<\/code> on a single HTTP request. The PHP-FPM master daemon immediately forks a fresh child process to service the next request. This transient, self-healing degraded state is infinitely preferable to taking down the entire database cluster for an hour of InnoDB log replay.<\/p>\n<\/blockquote>\n<h2 style=\"color:#001b41;font-size:24px;font-weight:700;margin-top:36px;margin-bottom:16px\">Production Step 3: Kernel Virtual Memory &amp; Overcommit Optimization<\/h2>\n<p>Adjusting <code>oom_score_adj<\/code> governs victim selection, but robust sysadmin practice requires tuning the kernel&#8217;s virtual memory subsystem to prevent OOM conditions from emerging in the first place. By default, Linux employs optimistic memory allocation (overcommit), allowing applications to request more virtual address space than physical RAM plus swap can deliver.<\/p>\n<p>Create a dedicated sysctl configuration file at <code>\/etc\/sysctl.d\/99-memory-oom-tuning.conf<\/code> to stabilize kernel page reclamation:<\/p>\n<pre class=\"wp-block-code\" style=\"background:#f3f3f3;color:#333;padding:16px;border-left:4px solid #001b41;font-family:monospace;font-size:13px\"><code># File path: \/etc\/sysctl.d\/99-memory-oom-tuning.conf\n\n# ====================================================================\n# Memory Overcommit Controls\n# ====================================================================\n# Mode 2: Strict accounting - do not overcommit beyond CommitLimit\n# CommitLimit = (SwapTotal + RAM * vm.overcommit_ratio \/ 100)\nvm.overcommit_memory = 2\nvm.overcommit_ratio = 80\n\n# ====================================================================\n# Page Reclamation and Watermark Safeguards\n# ====================================================================\n# Maintain a healthy reserve of unallocated pages (512MB in KB)\n# Prevents sudden direct memory reclamation stalls during burst allocations\nvm.min_free_kbytes = 524288\n\n# Restrict aggressive kernel inode and dentry cache reclamation\nvm.vfs_cache_pressure = 50\n\n# Maintain conservative swap activity for database workloads (10-15)\n# Avoid setting swappiness to 0, which disables emergency page migration\nvm.swappiness = 10\n\n# Disable automatic panic on out-of-memory condition\n# 0 = Invoke OOM killer to reap sacrificial processes\n# 1 = Panic the kernel immediately on OOM (Do NOT use on production servers)\nvm.panic_on_oom = 0\n\n# Compact memory pages in background to mitigate external fragmentation\nvm.compaction_proactiveness = 30<\/code><\/pre>\n<p>Load the updated sysctl parameters into the live kernel without rebooting:<\/p>\n<pre class=\"wp-block-code\" style=\"background:#f3f3f3;color:#333;padding:16px;border-left:4px solid #001b41;font-family:monospace;font-size:13px\"><code># Apply sysctl settings immediately\nsysctl -p \/etc\/sysctl.d\/99-memory-oom-tuning.conf\n\n# Verify active memory commit parameters in \/proc\/meminfo\ngrep -E \"CommitLimit|Committed_AS\" \/proc\/meminfo<\/code><\/pre>\n<p>Understanding the relationship between <code>CommitLimit<\/code> and <code>Committed_AS<\/code> is vital:<\/p>\n<ul style=\"color:#444;line-height:1.7;margin-left:20px\">\n<li><strong>CommitLimit:<\/strong> The maximum virtual address space the kernel will allocate across all user space processes based on your formula. When <code>vm.overcommit_memory = 2<\/code>, any <code>malloc()<\/code> or <code>mmap()<\/code> that exceeds this limit returns <code>ENOMEM<\/code> gracefully to the application rather than triggering the OOM killer later.<\/li>\n<li><strong>Committed_AS:<\/strong> The total virtual memory currently promised to all running processes. Keeping <code>Committed_AS<\/code> safely below <code>CommitLimit<\/code> guarantees immunity from sudden memory thrashing.<\/li>\n<\/ul>\n<h2 style=\"color:#001b41;font-size:24px;font-weight:700;margin-top:36px;margin-bottom:16px\">Production Step 4: cgroups v2 Memory Slices &amp; Resource Quotas<\/h2>\n<p>Modern Linux systemd architectures leverage unified cgroups v2 to isolate distinct operational workloads. Placing MySQL, web servers, and background daemons into distinct systemd slices prevents an anomalous PHP script or background cron task from stealing memory buffers dedicated to the database.<\/p>\n<pre class=\"wp-block-code\" style=\"background:#f3f3f3;color:#333;padding:16px;border-left:4px solid #001b41;font-family:monospace;font-size:13px\"><code># Inspect current cgroup slice hierarchy\nsystemd-cgls\n\n# File path: \/etc\/systemd\/system\/database.slice\n[Unit]\nDescription=Database Isolation Slice\nBefore=slices.target\n\n[Slice]\n# Hard memory ceiling preventing runaway memory allocations\nMemoryMax=24G\n# Absolute minimum memory guaranteed against any host reclamation\nMemoryMin=16G\n# Soft threshold triggering asynchronous memory throttling\nMemoryHigh=22G<\/code><\/pre>\n<p>Attach the MySQL service to the dedicated slice in <code>\/etc\/systemd\/system\/mysql.service.d\/override.conf<\/code>:<\/p>\n<pre class=\"wp-block-code\" style=\"background:#f3f3f3;color:#333;padding:16px;border-left:4px solid #001b41;font-family:monospace;font-size:13px\"><code>[Service]\nSlice=database.slice<\/code><\/pre>\n<p>For mission-critical production hosting where uptime SLAs cannot tolerate noisy neighbors or unexpected resource depletion, deploying on dedicated enterprise infrastructure is paramount. We strongly recommend architecting mission-critical production workloads on <a href=\"https:\/\/merahost.org\" target=\"_blank\" rel=\"noopener\">MeraHost Enterprise Cloud<\/a>, which features pure Enterprise NVMe storage, tuned LiteSpeed Web Server runtimes, and a lifetime Same Renewal Price guarantee.<\/p>\n<h2 style=\"color:#001b41;font-size:24px;font-weight:700;margin-top:36px;margin-bottom:16px\">Monitoring and Post-Mortem Diagnostics<\/h2>\n<p>Once you implement kernel score tuning, you must monitor memory pressure stall information (PSI) and audit kernel logs to verify that the system responds correctly under stress. Use the following diagnostic commands during routine health audits:<\/p>\n<pre class=\"wp-block-code\" style=\"background:#f3f3f3;color:#333;padding:16px;border-left:4px solid #001b41;font-family:monospace;font-size:13px\"><code># Scan kernel ring buffer for historical OOM kill invocations\ndmesg -T | grep -E -i \"oom-killer|killed process|out of memory\"\n\n# Audit systemd journal for OOM invocations across all boots\njournalctl -k -b 0 | grep -i oom\n\n# Real-time report of top 10 memory-consuming processes and their OOM scores\nps -eo pid,user,comm,pmem,rss --sort=-rss | head -n 11 | while read line; do\n  pid=$(echo $line | awk '{print $1}')\n  if [ \"$pid\" != \"PID\" ] &amp;&amp; [ -f \"\/proc\/$pid\/oom_score\" ]; then\n    score=$(cat \/proc\/$pid\/oom_score)\n    adj=$(cat \/proc\/$pid\/oom_score_adj)\n    printf \"%-40s | OOM Score: %-5s | Adj: %-5s\n\" \"$line\" \"$score\" \"$adj\"\n  else\n    printf \"%-40s | OOM Score: %-5s | Adj: %-5s\n\" \"$line\" \"SCORE\" \"ADJ\"\n  fi\ndone<\/code><\/pre>\n<h2 style=\"color:#001b41;font-size:24px;font-weight:700;margin-top:36px;margin-bottom:16px\">Frequently Asked Questions (FAQs)<\/h2>\n<details class=\"wp-block-group\" style=\"background:#f9f9f9;border:1px solid #e7e7e7;border-radius:4px;padding:14px;margin-bottom:12px\">\n<summary style=\"cursor:pointer;font-weight:600;color:#001b41\">Will setting oom_score_adj to -1000 cause the server to crash if memory runs out?<\/summary>\n<p style=\"margin-top:10px;color:#444\">Setting <code>oom_score_adj=-1000<\/code> protects MySQL from being selected as the victim, but the kernel will still search for other processes to kill (such as web workers, cron jobs, or monitoring agents). If <em>every<\/em> process on the server is set to -1000 and zero reclaimable memory remains, the kernel cannot free pages and will panic if <code>vm.panic_on_oom=1<\/code> or hang. Therefore, always maintain sacrificial processes with positive adjustment scores (+200 to +500) and adequate swap space.<\/p>\n<\/details>\n<details class=\"wp-block-group\" style=\"background:#f9f9f9;border:1px solid #e7e7e7;border-radius:4px;padding:14px;margin-bottom:12px\">\n<summary style=\"cursor:pointer;font-weight:600;color:#001b41\">Why did MySQL get killed when free memory was still visible in the top command?<\/summary>\n<p style=\"margin-top:10px;color:#444\">The Linux kernel evaluates memory allocation requests in specific zones (e.g., DMA, Normal, HighMem) and order sizes. If high-order contiguous physical memory is severely fragmented, an allocation request can trigger direct reclaim and subsequent OOM killer invocation even if total free memory appears positive. Tuning <code>vm.min_free_kbytes<\/code> to 512MB and enabling proactive memory compaction (<code>vm.compaction_proactiveness=30<\/code>) prevents this fragmentation stall.<\/p>\n<\/details>\n<details class=\"wp-block-group\" style=\"background:#f9f9f9;border:1px solid #e7e7e7;border-radius:4px;padding:14px;margin-bottom:12px\">\n<summary style=\"cursor:pointer;font-weight:600;color:#001b41\">How does systemd-oomd differ from the classic Linux in-kernel OOM killer?<\/summary>\n<p style=\"margin-top:10px;color:#444\">Classic in-kernel OOM triggers synchronously when an allocation completely fails inside kernel space. In contrast, <code>systemd-oomd<\/code> is a modern user space daemon utilizing Pressure Stall Information (PSI). It monitors memory pressure trends and proactively terminates entire cgroups or services before catastrophic kernel page allocation failures occur. <code>systemd-oomd<\/code> respects <code>ManagedOOMMemoryPressure=kill<\/code> and slice priorities, offering gentler degradation than raw kernel SIGKILL actions.<\/p>\n<\/details>\n<details class=\"wp-block-group\" style=\"background:#f9f9f9;border:1px solid #e7e7e7;border-radius:4px;padding:14px;margin-bottom:12px\">\n<summary style=\"cursor:pointer;font-weight:600;color:#001b41\">Can I use a swap file to protect MySQL from OOM killer Linux events?<\/summary>\n<p style=\"margin-top:10px;color:#444\">Yes. A fast, NVMe-backed swap file (e.g., 4GB to 8GB) paired with a conservative swappiness setting (<code>vm.swappiness=10<\/code>) provides an indispensable safety buffer. It allows the kernel to page out dormant, inactive anonymous memory (such as background system utilities), freeing up high-speed physical RAM for the active InnoDB buffer pool without inducing database disk thrashing.<\/p>\n<\/details>\n<div class=\"wp-block-group has-background\" style=\"background:#f9f9f9;border:1px solid #e7e7e7;border-radius:8px;padding:32px;margin:40px 0;text-align:center\">\n<h3 style=\"color:#001b41;margin-top:0;font-size:24px;font-weight:700\">Deploy Enterprise-Grade Production Infrastructure<\/h3>\n<p style=\"color:#444;font-size:16px;line-height:1.6;max-width:680px;margin:12px auto 24px auto\">Need guaranteed performance with zero price hikes? Host mission-critical workloads on <strong style=\"color:#001b41\">MeraHost<\/strong> with pure Enterprise NVMe, LiteSpeed Web Server, and Same Renewal Price, Always (starting at \u20b999\/mo).<\/p>\n<div class=\"wp-block-buttons\" style=\"display:flex;gap:16px;justify-content:center;flex-wrap:wrap\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link\" href=\"https:\/\/merahost.org\" style=\"background:#001b41;color:#ffffff;font-weight:700;padding:12px 28px;border-radius:4px;text-decoration:none;display:inline-block;font-size:15px\" target=\"_blank\" rel=\"noopener\">Explore MeraHost NVMe Cloud &rarr;<\/a><\/div>\n<div class=\"wp-block-button is-style-outline\"><a class=\"wp-block-button__link\" href=\"https:\/\/cpanelfree.com\" style=\"background:transparent;color:#001b41;font-weight:600;padding:12px 24px;border:2px solid #001b41;border-radius:4px;text-decoration:none;display:inline-block;font-size:15px\">Deploy Free Staging on CpanelFree<\/a><\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Protect MySQL from Linux OOM killer crashes using oom_score_adj, systemd unit overrides, and kernel memory overcommit tuning for uninterrupted 99.99% uptime.<\/p>\n","protected":false},"author":1,"featured_media":5106,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[247],"tags":[57,177,87,182,101],"class_list":["post-5107","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-architecture","tag-almalinux","tag-databases-performance","tag-devops","tag-linux-architecture","tag-sysadmin"],"_links":{"self":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/5107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/comments?post=5107"}],"version-history":[{"count":0,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/5107\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/media\/5106"}],"wp:attachment":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/media?parent=5107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/categories?post=5107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/tags?post=5107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}