Analyzer ngx-keepalive-statistics

Name

ngx-keepalive-statistics - Request/Upstream Connection Keep-alive Statistics

This analyzer collects comprehensive statistics on HTTP keep-alive connection behavior for both downstream client connections and upstream backend connections in Nginx-based applications such as OpenResty and Kong. It tracks keep-alive success rates, connection closures, and per-host connection patterns. The analyzer helps optimize connection pooling, identify keep-alive configuration issues, and understand connection reuse efficiency, which directly impacts application performance and resource utilization.

Resource Category

Network I/O.

Application Type & Technical Stack

  • OpenResty
  • Kong
  • APISIX

Command Line Syntax

The analyzer can be invoked directly on the command-line via the orxray utility from the openresty-xray-cli software package.

Alternatively, the analyzer can also be invoked manually or automatically on the web console UI of OpenResty XRay (like on the Advanced web page).

# PID is the target process PID.
orxray analyzer run ngx-keepalive-statistics -p PID

# trace a shell command directly
orxray analyzer run ngx-keepalive-statistics -c SHELL_CMD

# PGID is the process group ID or any process's PID within the target process
# group.
orxray analyzer run ngx-keepalive-statistics -p -PGID

# trace any processes started from the specified executable path.
orxray analyzer run ngx-keepalive-statistics --exe /path/to/exe/file

Tracing Multiple Processes

Supported.

Output Formats

  • Plain Texts

Output Example

{
  "stats": {
    "request_closed": 13,
    "request_keepalived_percent": 56,
    "request_keepalived": 17,
    "upstream_closed": 0,
    "upstream_keepalived": 2,
    "upstream_keepalived_percent": 100
  },
  "upstream-closed-hosts": {},
  "request-closed-hosts": {
    "test.com": 11,
    "doc.test.com": 2
  },
  "upstream-keepalived-hosts": {
    "test.com": 1,
    "doc.test.com": 1
  },
  "request-keepalived-hosts": {
    "test.com": 8,
    "test.org": 4,
    "abc.test.com": 2,
    "opm.test.org": 1
  }
}

Author

The OpenResty Inc. Team.

Copyright (C) by OpenResty Inc. All rights reserved.