{"id":1692,"date":"2026-11-12T23:09:34","date_gmt":"2026-11-12T23:09:34","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=1692"},"modified":"2026-11-12T23:09:34","modified_gmt":"2026-11-12T23:09:34","slug":"minor-major-page-faults-php-fpm-memory-pressure","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/minor-major-page-faults-php-fpm-memory-pressure\/","title":{"rendered":"Minor vs Major Page Faults: Measuring PHP-FPM Behaviour Under Memory Pressure"},"content":{"rendered":"<div style=\"padding:20px\">\n\n<p class=\"wp-block-paragraph\">A PHP-FPM worker&#8217;s RSS goes from 48 MB to 140 MB over three days and nobody deployed anything. <code>free -m<\/code> shows plenty of available memory, yet latency climbs and the OOM killer eventually takes the worker. The explanation is usually in minor faults per second, not in RSS growth: an application allocating and freeing small chunks in a loop pays a page fault for every touched mapping, and each fault carries scheduler and TLB cost that <code>top<\/code> folds into softirq-adjacent noise. You can also <a href=\"https:\/\/virtualserversvps.com\/\">compare the VPS plans behind these numbers<\/a> before you commit.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Page faults are cheap individually and ruinous in aggregate. This is a measurement workflow that separates minor from major faults per process, attributes the cost to a specific PHP code path, and tells you whether the fix is allocator tuning, a memory limit, or a host-level RAM guarantee.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Minor versus major, and why the ratio is the signal<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A minor fault maps a page that exists in the page cache or in the process&#8217;s anonymous memory but is not yet in the page table. It costs a trap, a zero or a copy of a 4 KiB frame, and entry into the fault handler\u2014single-digit microseconds. A major fault has to reach block storage, which is tens to thousands of microseconds depending on whether the backing file is on NVMe or swap. The ratio between them tells you whether you have a mapping problem or a memory-pressure problem.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On a healthy PHP-FPM pool, minor faults run in the hundreds per second per worker while serving requests, and majors are effectively zero after opcache warms. Majors climbing steadily means pages are being reclaimed and re-faulted: swap thrashing, or an anonymous mapping that exceeds what the host has actually committed to you.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Per-process fault counters with pidstat<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>pidstat -r -p &lt;pid&gt; 5<\/code> prints minflt\/s, majflt\/s and VSZ\/RSS per interval. Use the <code>-C<\/code> selector to watch every worker at once, and send the output to a file so you can compare intervals after the fact:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pidstat -r -C php-fpm8.3 5 120 &gt; \/var\/log\/faults.log\ngrep -v '^Average' \/var\/log\/faults.log | awk '$4+$5&gt;0'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Note that pidstat&#8217;s minflt counter can be affected by the kernel&#8217;s task-memory accounting granularity; the per-second rate is reliable, the absolute since-boot figure is not. Compare rates under identical request load: run the same <code>ab<\/code> or <code>wrk<\/code> pass during an idle period and during peak, and the delta in minflt\/s attributable to concurrency becomes visible.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Watch the pool, not just one worker<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">PHP-FPM pre-forks, so a pool of 20 workers with 300 minflt\/s each is 6,000 faults per second for the box\u2014enough to consume a meaningful slice of a small vCPU. Sum across the pool with <code>pidstat -r -C php-fpm8.3 1 1 | awk<\/code> and divide by vCPU count to express the cost as a percentage of a core. Rough guidance: 10,000 minor faults per second costs roughly 3\u20135% of a modern core in fault entry alone, before the page-zeroing work.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also check whether the faults are spread or concentrated. One worker with a high minflt rate and the rest quiet points at a specific endpoint or an extension; uniform rates across all workers point at the allocator, the opcache configuration, or a shared code path in every request.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Attribute the faults to a code path<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>perf record -e page-faults -g -p &lt;pid&gt; -- sleep 30<\/code> then <code>perf report<\/code> gives a call-graph view of who triggers the faults. For PHP this lands in <code>zend_mm_alloc<\/code>, <code>mmap<\/code>, or an extension&#8217;s buffer growth. Seeing faults concentrated in a single extension is actionable: it is usually a per-request allocation of a large temporary buffer that could be reused.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Where perf is unavailable, <code>\/proc\/&lt;pid&gt;\/stat<\/code> fields 10 and 12 (minflt and majflt) sampled once a second gives the same rate without kernel tracing, and pairs well with the request log if you correlate by timestamp. A spike aligned with a specific route in the access log is the fastest attribution path there is.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Separating allocator churn from reclaim<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If major faults appear only when RSS exceeds a threshold, and <code>vmstat 1<\/code> shows <code>si<\/code>\/<code>so<\/code> moving at the same moment, the process is being pushed into swap by pressure. Check <code>\/proc\/&lt;pid&gt;\/smaps_rollup<\/code> for <code>Swap:<\/code> and compare <code>MemAvailable<\/code> in <code>\/proc\/meminfo<\/code>\u2014a gap between what PHP-FPM reports as committed and what the host actually provides is the signature of a ballooning guest.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If RSS is stable, swaps are zero, and minors are high, the cause is allocator fragmentation: glibc&#8217;s per-thread arenas keep growing and returning pages to the kernel only under <code>M_TRIM_THRESHOLD<\/code>, so each request faults new pages that were never reused. Values from <code>malloc-trim<\/code> in the FPM pool config or switching to jemalloc change the fault rate measurably, and the measurement above is how you prove it rather than assume it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Testing under controlled pressure<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Reproduce deliberately: run a load test at normal concurrency, record minflt\/s and majflt\/s, then hold 85% of RAM with <code>stress-ng --vm 1 --vm-bytes 85% --vm-keep<\/code> and repeat. A pool that is healthy at baseline and shows double-digit major faults per second under pressure is one whose memory is not reserved\u2014an allocation policy question rather than an application bug.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Transparent hugepages and the fault rate<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">THP changes the fault picture: a 2 MiB hugepage is faulted in as a single event, so minflt\/s drops sharply while the cost per fault rises by an order of magnitude. A PHP worker that shows a sudden fall in minor faults after a kernel change has not become faster \u2014 it is faulting hugepages. <code>grep AnonHugePages \/proc\/&lt;pid&gt;\/smaps_rollup<\/code> confirms whether the pool is using them, and <code>\/sys\/kernel\/mm\/transparent_hugepage\/enabled<\/code> shows the policy.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Measure latency alongside the fault rate rather than instead of it. For a process doing fine-grained allocation, THP is a net loss because the zeroing cost of a 2 MiB page lands on the request that first touches it; for a process with large anonymous regions it removes millions of faults. The fault counters tell you which of the two you have, and the p99 tells you whether the trade was worth it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That distinction decides who fixes it. Allocator and opcache changes are yours; guaranteed RAM is a plan question, and <a href=\"https:\/\/virtualserversvps.com\/vps-vs-dedicated-server\">our VPS plan comparison<\/a> is where the committed-versus-allocated difference is laid out. For pressure-driven fault behaviour that follows from how the kernel manages page cache, <a href=\"https:\/\/virtualserversvps.com\/managed-vs-unmanaged\">see the managed vs unmanaged breakdown<\/a>. Either way, record the fault rates before and after each change \u2014 they move more reliably than wall-clock latency.<\/p>\n\n<\/div>","protected":false},"excerpt":{"rendered":"<p>A PHP-FPM worker&#8217;s RSS goes from 48 MB to 140 MB over three days and nobody deployed anything. free -m shows plenty of available memory, yet latency climbs and the&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":1,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1692","post","type-post","status-publish","format-standard","hentry","category-vps-guides-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Minor vs Major Page Faults: Measuring PHP-FPM Behaviour Under Memory Pressure - Virtual Servers VPS Blog<\/title>\n<meta name=\"description\" content=\"A PHP-FPM worker&#039;s RSS goes from 48 MB to 140 MB over three days and nobody deployed anything. free -m shows plenty of available memory, yet latency\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/virtualserversvps.com\/blog\/minor-major-page-faults-php-fpm-memory-pressure\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Minor vs Major Page Faults: Measuring PHP-FPM Behaviour Under Memory Pressure\" \/>\n<meta property=\"og:description\" content=\"Minor vs Major Page Faults: Measuring PHP-FPM Behaviour Under Memory Pressure\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/minor-major-page-faults-php-fpm-memory-pressure\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-12T23:09:34+00:00\" \/>\n<meta name=\"author\" content=\"Virtual-Servers-Vps-Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Virtual-Servers-Vps-Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/minor-major-page-faults-php-fpm-memory-pressure\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/minor-major-page-faults-php-fpm-memory-pressure\/\",\"name\":\"Minor vs Major Page Faults: Measuring PHP-FPM Behaviour Under Memory Pressure - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-11-12T23:09:34+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"description\":\"A PHP-FPM worker's RSS goes from 48 MB to 140 MB over three days and nobody deployed anything. free -m shows plenty of available memory, yet latency\",\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/minor-major-page-faults-php-fpm-memory-pressure\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/minor-major-page-faults-php-fpm-memory-pressure\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/minor-major-page-faults-php-fpm-memory-pressure\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Minor vs Major Page Faults: Measuring PHP-FPM Behaviour Under Memory Pressure\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/\",\"name\":\"Virtual Servers VPS Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\",\"name\":\"Virtual-Servers-Vps-Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"caption\":\"Virtual-Servers-Vps-Editor\"},\"sameAs\":[\"https:\/\/virtualserversvps.com\/blog\"],\"url\":\"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Minor vs Major Page Faults: Measuring PHP-FPM Behaviour Under Memory Pressure - Virtual Servers VPS Blog","description":"A PHP-FPM worker's RSS goes from 48 MB to 140 MB over three days and nobody deployed anything. free -m shows plenty of available memory, yet latency","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/virtualserversvps.com\/blog\/minor-major-page-faults-php-fpm-memory-pressure\/","og_locale":"en_US","og_type":"article","og_title":"Minor vs Major Page Faults: Measuring PHP-FPM Behaviour Under Memory Pressure","og_description":"Minor vs Major Page Faults: Measuring PHP-FPM Behaviour Under Memory Pressure","og_url":"https:\/\/virtualserversvps.com\/blog\/minor-major-page-faults-php-fpm-memory-pressure\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-11-12T23:09:34+00:00","author":"Virtual-Servers-Vps-Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Virtual-Servers-Vps-Editor","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/virtualserversvps.com\/blog\/minor-major-page-faults-php-fpm-memory-pressure\/","url":"https:\/\/virtualserversvps.com\/blog\/minor-major-page-faults-php-fpm-memory-pressure\/","name":"Minor vs Major Page Faults: Measuring PHP-FPM Behaviour Under Memory Pressure - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-11-12T23:09:34+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"description":"A PHP-FPM worker's RSS goes from 48 MB to 140 MB over three days and nobody deployed anything. free -m shows plenty of available memory, yet latency","breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/minor-major-page-faults-php-fpm-memory-pressure\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/minor-major-page-faults-php-fpm-memory-pressure\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/minor-major-page-faults-php-fpm-memory-pressure\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Minor vs Major Page Faults: Measuring PHP-FPM Behaviour Under Memory Pressure"}]},{"@type":"WebSite","@id":"https:\/\/virtualserversvps.com\/blog\/#website","url":"https:\/\/virtualserversvps.com\/blog\/","name":"Virtual Servers VPS Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0","name":"Virtual-Servers-Vps-Editor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","caption":"Virtual-Servers-Vps-Editor"},"sameAs":["https:\/\/virtualserversvps.com\/blog"],"url":"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/"}]}},"_links":{"self":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1692","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/comments?post=1692"}],"version-history":[{"count":4,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1692\/revisions"}],"predecessor-version":[{"id":1704,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1692\/revisions\/1704"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=1692"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=1692"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=1692"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}