Skip to main content

Cloudsoft Zone Build, deploy and scale with practical guides to PHP, Node.js, React, DevOps and AI automation. Explore the guides

Cloudsoft Zone
DevOpsDevelopmentMySQLPHPTutorial

Production stack monitoring: nginx, PHP-FPM, MySQL, Redis and queue workers

Build production stack monitoring with private nginx and PHP-FPM status, MySQL connection signals, Redis memory context and queue progress instead of process-only checks.

Nilesh Kushvaha

5 min read

Sourced nginx artwork with a production monitoring sequence across PHP-FPM, MySQL, Redis and queue workers.
Image: Cloudsoft Zone layout; Igor Sysoev / Public domain
In this article

Requests are timing out, but nginx is running, PHP-FPM is running and MySQL accepts connections. Restarting every service destroys useful evidence and can interrupt work without addressing the bottleneck.

Production stack monitoring should reveal which layer is waiting, which resource is constrained and whether useful work still completes. This guide covers nginx, PHP-FPM, MySQL, Redis and queue workers without treating process liveness as application health.

Use our Laravel production checklist for release readiness. The examples below are reader configuration fragments, not changes to a running deployment.

Request monitoring follows nginx connections into PHP-FPM pool capacity and dependency pressure.
A symptom at nginx can originate deeper in the stack.

Step 1: Define the question for each component

Record the public symptom first: affected route, start time, release identifier and expected behavior. Then collect component observations for that same interval. Comparing today's latency with last week's maximum connection count produces a weak diagnosis.

Layer Useful question Supporting signal
nginx Is the edge waiting on an upstream? Response outcomes and upstream timings
PHP-FPM Are requests waiting for a free process? Listen queue, active processes and pool capacity
MySQL Are connections or active queries constrained? Connection pressure and query or lock evidence
Redis Is its role operating within memory and persistence limits? Memory, errors, evictions and role-specific behavior
Workers Is accepted background work progressing? Age, completions, failures and retries

Define which observations justify an urgent response. Some growth trends belong in capacity planning; a stopped payment workflow deserves different handling.

Step 2: Collect nginx status privately

Check whether the installed nginx build includes the stub status module. It is not built by default in upstream nginx, although distribution packages can include it.

This example assumes an available host-local port and an authorized collector on that same host:

Nginx
server {
    listen 127.0.0.1:8081;
    server_name localhost;

    location = /nginx-status {
        stub_status;
        allow 127.0.0.1;
        deny all;
    }
}

Validate the configuration with nginx's configuration check before an owned reload. A container's loopback address is a different network boundary; do not publish this listener to the internet to make an exporter reach it.

Stub status provides connection and request counters, not per-route error rates or application latency. Derive rates with counter-reset awareness. Active connections include waiting connections, so a large total does not necessarily mean every connection is executing application work.

Step 3: Read PHP-FPM pool pressure

Enable and route the status path through the existing private FastCGI configuration. Setting pm.status_path alone does not create a safe HTTP endpoint. Restrict access before enabling detailed collection.

Compare the listen queue, active and idle processes, current pool configuration and memory pressure. A maximum-children counter records that the limit was reached; interpret its change over the observation window rather than treating an old nonzero value as a fresh incident.

PHP supports a separate status listener that can answer independently when the main pool is occupied. That improves observability, but it does not establish that normal application requests are healthy.

Avoid increasing process counts immediately. More PHP processes can consume the remaining host memory and create more simultaneous database work. Measure process memory and dependency capacity before changing concurrency.

MySQL connections, Redis workload pressure and queue progress provide complementary monitoring evidence.
A blocking queue client and a cache eviction are not automatically incidents.

Step 4: Separate database connections from database work

Using an authorized monitoring connection on the intended MySQL instance, this read-only query selects a small set of global observations:

SQL
SHOW GLOBAL STATUS
WHERE Variable_name IN (
  'Threads_connected',
  'Threads_running',
  'Max_used_connections',
  'Connection_errors_max_connections'
);

Confirm account privileges and version-specific meanings before relying on the output. Open connections differ from actively executing work. A historical maximum is not current utilization, and a refused-connection counter needs a time window.

Correlate these signals with application pool waits, query latency and lock evidence. Raising the server connection limit can worsen memory pressure when the actual cause is slow queries or excessive application concurrency.

Step 5: Interpret Redis by its workload

Use bounded INFO sections through an existing authorized client. Keep the raw diagnostic output private. Do not enable broad command tracing as a routine monitoring substitute: commands can carry sensitive payloads and collection has an operational cost.

Distinguish logical memory usage from process resident memory. Examine evictions, rejected connections and persistence errors in the context of the configured role.

A cache can deliberately evict expendable values. A queue broker requires a different loss and persistence contract. Blocking clients can be legitimate queue consumers; investigate progress rather than declaring every blocked client unhealthy.

Step 6: Monitor worker progress

Track the oldest relevant job age, completion rate, retries and failed jobs. Separate priority queues where service expectations differ. Worker process presence alone cannot prove that it is consuming the correct connection and queue.

Laravel's queue monitoring can report excessive queue counts, but the notification listener and delivery channel still need configuration. Queue depth also needs context: many quickly completed jobs differ from a few jobs stalled for an hour.

Our Laravel queues and BullMQ comparison explains the application-level boundaries.

Observation First bounded investigation
FPM backlog rises Compare pool saturation, request duration and memory
Database waits rise Inspect slow work and application concurrency
Redis evictions change Confirm workload role and memory policy
Queue age rises Confirm consumers, failures and dependency availability

Monitoring verification connects a defined time window, a controlled alert rehearsal and workflow recovery.
Do not close an incident solely because processes restarted.

Step 7: Rehearse failure detection and recovery

In an isolated environment, exercise missing collection, stalled queue consumption and an unavailable dependency. Confirm that the alert identifies the right component, reaches its owner and links a bounded response.

After mitigation, recheck the original request or background outcome and observe stability. Preserve before-and-after evidence with timestamps; do not substitute a restart for proof.

For a monitoring design matched to your application's workload and operating team, discuss your project with Cloudsoft Zone.

Featured image: Cloudsoft Zone technical layout with nginx artwork by Igor Sysoev (Public domain). Product mark resized proportionally for identification; no endorsement implied. Layout: CC BY-SA 4.0.

Frequently asked questions

  • Does nginx stub status report application latency?

    No. It reports basic connection and request counters. Use application instrumentation or appropriately designed access-log metrics for latency and response outcomes.

  • Is a PHP-FPM status endpoint safe to expose publicly?

    No. Restrict it to authorized monitoring clients. Detailed output can reveal internal requests, script paths and process information.

  • Should a high Redis blocked-client count always trigger a page?

    No. Blocking consumers can be normal for queues. Interpret the count with queue age, progress, connection limits and the intended workload.

Sources

  1. nginx basic status module — nginx
  2. PHP-FPM status fields — PHP
  3. PHP-FPM pool configuration — PHP
  4. MySQL 8.4 server status variables — MySQL
  5. Redis INFO sections — Redis
  6. Laravel queue monitoring — Laravel

New tools, once a week

One short email listing what joined the directory.

The weekly email about new tools and occasional newsletters. Unsubscribe at any time.

Comments

No comments yet. Be the first to join the conversation.

Leave a comment

Every comment is read by a moderator before it appears. Your email address is never published; it is used only to contact you about this comment.

Never published. Used only to contact you about this comment.

Loading the security check…

Comments are moderated before publication.