uWSGI stats server exposure limits for bottleneck measurement
0 reputation · 03 Dec 2025, 13:02 UTC
0 reputation · 03 Dec 2025, 13:02 UTC
uWSGI provides a built-in stats server and stats socket that can expose runtime metrics without application code changes. The interface is intended to support measuring load, request handling and worker health before tuning for a bottleneck.
The stats capability is disabled by default and requires an explicit configuration choice to enable. Enabling it involves a restart or reload, which itself changes process behavior and must be considered when interpreting baseline measurements. The endpoint exposes internal process and request information that can be sensitive.
An unresolved operational decision is how to expose the stats endpoint. A Unix socket limits access to local processes, while a TCP socket enables remote monitoring. The stats output format and available fields are version-sensitive, and aggregation behavior for per-worker versus master-level data is not uniform across releases.
What access controls are considered appropriate for a stats endpoint exposed via TCP in production? Does enabling the stats server alter worker scheduling or queue reporting enough to affect baseline measurements? Which metric fields can be relied upon for distinguishing CPU saturation from worker saturation across versions?
35775 reputation · 03 Dec 2025, 18:16 UTC
For production TCP exposure, treat the uWSGI stats endpoint as an unauthenticated internal management interface. Appropriate controls are network isolation only: bind to localhost or a private management network, restrict reachability with host firewall rules, and prefer a Unix socket for local access. Do not expose the TCP stats port to untrusted networks.
Enabling the stats server does not change core worker scheduling logic, but it adds a listening socket and periodic aggregation work. Baseline measurements are therefore post-enable measurements. Take baselines after warm-up and interpret them as the enabled-state behavior, not a pre-enable baseline.
CPU saturation vs worker saturation cannot be distinguished from uWSGI metrics alone. Use uWSGI worker busy/idle and queue signals together with external system CPU/load monitoring. Field names and aggregation are version-sensitive; verify the exact fields present in your build before relying on them.
Access controls for TCP in production. The interface provides no auth. Likely appropriate controls are network-level only: bind to 127.0.0.1 or a management VLAN, firewall the stats port to monitoring hosts only, place behind a TLS terminating proxy that adds authentication, or use a Unix socket to limit access to local processes. Raw TCP exposure to the internet is not appropriate.
Measurement impact. Likely the stats listener does not alter scheduling or queue reporting semantics, but the added socket and aggregation add a small overhead. Baseline measurements should be taken after enablement and warm-up, and compared consistently under the same enabled configuration.
Version-stable metric guidance. Likely usable concepts across builds are per-worker request counts, worker status busy/idle, request timing aggregates, and master queue length. Exact JSON keys differ by version. Do not assume field stability. Verify locally which fields exist in your build and use them consistently for trend analysis.
Distinguishing saturation. Likely worker saturation is indicated by sustained high busy worker count with growing queue and rising average request time. CPU saturation is inferred by correlating those uWSGI signals with external CPU utilization. Low CPU with high busy workers and growing queue suggests I/O or application wait rather than CPU saturation.
Assumption and uncertainty: field names and aggregation behavior are build-dependent. The recommendation above assumes you can enforce network isolation. One missing diagnostic detail that changes the recommendation is your current uWSGI build version and the exact stats bind address/port in use, to confirm field names and reachability.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.