Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

Why a Long PHP Script Blocks Other Requests on Nginx PHP-FPM

A long PHP script occupies one PHP-FPM child. When every child is busy, Nginx's FastCGI requests wait in the pool queue. This guide explains the mechanics, diagnosis, safe worker sizing, and fixes that protect interactive pages.
Length9 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A long PHP request does not usually freeze Nginx itself. It occupies one PHP-FPM child process; when every child in the pool is already serving a request, new PHP requests wait in the FastCGI queue. The apparent Nginx blockage is therefore a PHP-FPM concurrency limit, most often pm.max_children, combined with a slow endpoint.

What actually happens when a PHP request arrives

Nginx accepts the client connection and matches the request to a location block. For a PHP route, the fastcgi_pass directive forwards the request to a PHP-FPM listener over FastCGI. PHP-FPM then assigns the request to an available child process in the selected pool.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A child normally handles one PHP request at a time. It cannot start handling another request while it is waiting on a database, calling a remote API, reading a large file, running a loop, or generating an export. If a script runs for 90 seconds, its child is unavailable for those 90 seconds even if the CPU is otherwise idle.

Suppose a pool has eight children. Eight concurrent requests can occupy all eight slots, including one request that is unexpectedly slow. A ninth PHP request is not executed immediately; it waits for a child to become free. As more requests arrive, the listen queue grows and users see delayed pages, gateway errors, or application timeouts. Static files and responses produced without PHP can still be served by Nginx, which is why the entire web server may appear healthy while PHP-backed pages stall.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

The setting that creates the ceiling: pm.max_children

PHP-FPM’s pm.max_children setting is the hard limit on simultaneous requests served by a pool. In static mode it is the fixed number of children kept running. In dynamic and ondemand modes it is the maximum number that may exist, so it remains the upper bound on concurrent PHP work.

Process manager mode How children are created Relevant controls What a slow script does
static Maintains a fixed child count equal to pm.max_children. pm.max_children Consumes one fixed slot until the request ends.
dynamic Starts and retires children within a configured range. pm.max_children, pm.start_servers, pm.min_spare_servers, pm.max_spare_servers Uses one slot; enough slow requests can exhaust the maximum.
ondemand Starts children when requests arrive and removes idle children after pm.process_idle_timeout. pm.max_children, pm.process_idle_timeout Uses one slot and may also incur process-start latency for new work.

The mode changes how capacity is maintained, not the basic rule: once all permitted children are busy, additional PHP requests queue. A copied sample value is not a safe capacity plan. Each PHP worker has a memory footprint, and increasing the ceiling can cause swapping or an out-of-memory kill if the host cannot hold the extra processes.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why Nginx buffering cannot solve the queue

Nginx’s FastCGI response buffering controls how response bytes are read from PHP-FPM and forwarded to the client. Buffer sizes and temporary-file behavior can affect transfer efficiency for large responses, but they do not create additional PHP-FPM children or make a running script finish sooner.

Changing buffering may help a response that is already being generated but is slow to deliver. It will not help a request that is waiting for an available worker, blocked inside PHP, or stalled on a database query. Treat the FastCGI upstream queue and response buffering as separate mechanisms.

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

How to prove that PHP-FPM is the bottleneck

1. Inspect pool status while the problem is happening

Enable the FPM status page for the affected pool according to your distribution’s pool configuration, then observe active processes, idle processes, the maximum active-process count, and the listen queue. A growing queue with no idle children indicates that requests are waiting for capacity rather than being rejected by Nginx routing.

PHP also provides pm.status_listen, an independent status listener. It can continue serving status information even when the main pool is saturated by long-running requests, making it useful during an incident. Protect any status endpoint with network restrictions or authentication; it exposes operational details.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Turn on the slow log

Configure the pool’s request_slowlog_timeout and slowlog settings, using thresholds appropriate for the application. The slow log records a PHP backtrace when a request exceeds the threshold. It can reveal the exact function or call where time is being spent instead of merely showing that Nginx waited.

3. Correlate Nginx and FPM timings

Compare Nginx upstream timing fields with FPM access or error logs. A request can spend time waiting before PHP starts, time executing in PHP, and time transmitting the response. Distinguishing those phases prevents a slow database query from being misdiagnosed as a network or buffering problem.

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

4. Identify the work that holds the child

  • Database queries waiting on locks, missing indexes, or large result sets.
  • Remote HTTP calls without strict connect and read timeouts.
  • Filesystem scans, archive creation, image or video processing, and large report exports.
  • Unbounded loops, recursive code, or accidental polling.
  • Memory pressure that causes swapping and makes every worker slower.

5. Check whether unrelated routes share the pool

Many installations send every PHP route to one pool. In that arrangement, a batch export, game-library import, or administrative task can consume the same children used by login, page rendering, or an API. Confirm the pool assignment before changing global limits.

How to size pm.max_children safely

Set the ceiling from measurements, not from a generic “high traffic” value. First measure the resident memory of representative PHP-FPM children under realistic load. Include the application’s baseline memory, loaded extensions, peak request allocations, and any per-request growth. Then reserve memory for the operating system, Nginx, the database client or local database, queues, caches, and monitoring.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A practical upper bound is:

usable_memory_for_fpm / measured_peak_memory_per_child

Round down and leave a safety margin. The result is a memory limit, not an automatic performance target. CPU also constrains useful concurrency: if workers are CPU-bound, adding children beyond available cores can increase context switching and latency. If they are mostly waiting on I/O, more concurrency may help, but only until the database or remote service becomes the next bottleneck.

Validate the estimate during a controlled load test or a representative production window. Watch resident memory, swap activity, CPU saturation, FPM queue length, request duration, and error rates. Raise the value gradually, reload FPM safely, and keep a rollback value. If memory begins to reclaim or swap, reduce the limit rather than allowing the host to thrash.

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

Fix the slow request instead of only adding workers

Make the user-facing request short

Move expensive work out of the request/response path. The PHP endpoint can validate input, create a durable job record, enqueue work, and return a job identifier. A worker process then performs the export, import, media conversion, or other long task. The client can poll a status endpoint or receive a notification when the job is complete.

Design the job for retries: use an idempotency key, persist progress and failure state, and make duplicate delivery safe. Set queue visibility or lease timeouts longer than the expected task duration, and provide a way to resume or cancel a job. Returning quickly protects interactive capacity, but it does not remove the need to control worker concurrency and downstream limits.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use strict dependency timeouts

Every database and remote HTTP operation should have explicit connect, read, and overall deadlines. A request that waits indefinitely can occupy a child until an infrastructure timeout fires. Timeouts should produce a controlled error and useful logs, not a half-completed write.

Split pools for different traffic classes

Create a separate FPM pool for slow, trusted, or batch endpoints when practical. Route those URLs to the batch pool and leave the interactive pool with its own process limit. This provides failure isolation: a stuck export can exhaust its pool without consuming every child that serves pages or game APIs.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
Architecture Latency for interactive pages Failure isolation Operational cost Important trade-off
One shared pool Can degrade sharply when any route is slow. Low; all routes compete for the same children. Lowest configuration complexity. Simple to operate, but noisy-neighbor effects are large.
Separate interactive and batch pools Interactive latency remains protected if batch capacity is exhausted. Higher; each class has an independent ceiling. Requires routing, separate limits, and monitoring. Capacity is partitioned, so unused slots in one pool cannot automatically serve the other.
Queued background worker Short request latency after enqueueing. High when worker concurrency and retries are controlled. Highest; adds a queue, worker lifecycle, and job-state handling. Results are asynchronous and require retry-safe application logic.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Using fastcgi_finish_request() correctly

fastcgi_finish_request() flushes the response to the client so the connection can close before PHP performs additional work. It can improve perceived latency for tasks that must happen after a response, such as lightweight logging or cleanup.

It does not free the FPM child. The PHP process remains occupied until all post-response work ends, so enough such requests can still fill the pool. Do not use it as a substitute for a queue when the work is CPU-heavy, I/O-heavy, failure-prone, or expected to run for a long time. Ensure that session locks, database transactions, output buffering, and application shutdown handlers are safe before continuing after the response.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Timeouts are guardrails, not a cure

Set PHP-FPM’s request_terminate_timeout and matching application-level timeouts to stop runaway requests. Choose values that allow legitimate work to complete while bounding damage from deadlocks, infinite loops, or an unavailable dependency. A terminated request may leave partial files or database changes, so make operations transactional or resumable where possible.

Also review Nginx FastCGI connect, read, and send timeouts. If Nginx gives up before PHP finishes, the client may see an error while the FPM child continues working, depending on the application and server behavior. Align these limits deliberately and log which layer ended the request.

Common symptoms and the right response

Symptom Likely explanation First action
PHP pages queue while static files remain fast All children in the PHP pool are busy. Check FPM active/idle counts and the listen queue.
Raising pm.max_children makes the host swap The new process count exceeds available memory. Measure worker memory, reduce the ceiling, and find the slow work.
Only exports or admin jobs trigger outages Long endpoints share the interactive pool. Queue them or route them to an isolated pool.
Workers are active but the slow log points to a dependency PHP is waiting on a database, remote service, or filesystem. Add dependency timeouts and fix the underlying call.
Requests fail at a consistent elapsed time A configured timeout is terminating the request. Identify whether FPM, PHP, Nginx, or the upstream dependency owns that timeout.

A repeatable incident procedure

  1. Record the affected URLs, start time, response codes, and whether static content is also slow.
  2. Open the FPM status view, preferably through the independent pm.status_listen listener, and capture active children, idle children, maximum active processes, and queue length.
  3. Inspect the slow log and correlate request identifiers with Nginx upstream timings.
  4. Stop or throttle the offending batch job if doing so is safe; do not repeatedly restart FPM without preserving evidence.
  5. Apply a temporary guardrail, such as a queue limit, dependency timeout, or route-level rate limit.
  6. Choose a permanent fix: optimize the operation, move it to a queue, isolate its pool, or revise worker capacity after memory and CPU measurements.
  7. After the change, verify queue depth, tail latency, memory, swap, CPU, and error rates under representative traffic.

Is Nginx or PHP-FPM causing the timeout?

Use the phase where time accumulates to answer that question. If the FPM listen queue is full and no children are idle, PHP-FPM capacity is the immediate bottleneck. If a child is running and the slow log identifies a query or remote call, the application or dependency is slow. If PHP completes quickly but bytes take a long time to reach the client, investigate response transmission or buffering. Nginx is the component that forwards and times the upstream exchange, but it does not supply PHP execution workers.

The durable solution is to keep synchronous PHP work bounded, expose queue pressure and slow traces, isolate workloads that have different latency goals, and size each pool against measured memory and CPU. Increasing pm.max_children is useful only when the host and downstream systems can safely support the additional concurrency.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.