How to find the number of incoming requests to a apache server and also the maximum number of requests that it can serve? Is it possible to extract this info to use it in a program??

Dani AI

Generated

Short answer and a few practical ways to proceed.

There is a difference between "connections" and "HTTP requests." Tools that list TCP sockets (what pointed to) show connections, not necessarily one HTTP request each. Modern browsers open multiple parallel connections and HTTP/2 can carry many requests on a single connection, so counting sockets can be misleading (this is what was arguing and partly defended). For a reliable view you need request-level visibility or Apache's internal worker state, not just a socket dump.

For real-time, per-worker info enable Apache's mod_status (protect it by IP/basic auth) and turn on ExtendedStatus. The machine-readable page can be polled and parsed; for example you can fetch and extract busy/idle worker counts programmatically:

curl -s http://127.0.0.1/server-status?auto \
  | awk -F': ' '/BusyWorkers/ {b=$2} /IdleWorkers/ {i=$2} END {print "busy=" b " idle=" i}'

That gives an immediate picture of how many workers are serving requests vs idle. ExtendedStatus has small overhead; keep server-status access locked down.

For total/request rates and historical numbers use the access log or a log-collector. Tools like goaccess, apachetop or a metrics pipeline (Fluentd/Logstash -> Prometheus/Grafana) give reliable request/sec and percentiles. Simple programmatic approach: tail or parse access_log for the time window you care about and count lines; for production monitoring use an exporter or agent that emits rates rather than running ad-hoc greps.

About the "incoming request queue": the kernel keeps accept/SYN queues and Apache has its backlog and MPM worker limits. Inspect listening-socket queues and TCP state with ss (e.g. ss -ltn and ss -s) to see queued connections and SYN_RECV counts. If queues fill, tune kernel knobs (somaxconn, tcp_max_syn_backlog), Apache's listen/backlog and the MPM worker limits (MaxRequestWorkers in modern Apache). Also check ulimits and file-descriptor capacity—raising backlog without enough workers or FDs will only mask the real bottleneck.

Recommended Answers

All 4 Replies

The number of currently incomming requests can be found using netstat:
netstat -anp | grep :80

Just read the number where the destination address is your servers ip with the port 80.

To find the maximum number of requests apache can handle just look in the httpd.conf file for the MaxClients directive. There should be some other information regarding child processes and how many clients per process each can hold.

Thank you for the help, I got the incoming reuests. Is there a way to find the incoming request queue?

The number of currently incomming requests can be found using netstat:

Bullshit. What you see with netstat is the amount of connections a client has made - modern browsers tend to open up to ten connections at the same time for one single request.

the suggestion of blud is correct, on a server platform you can check the incoming connections through netstat command, it's quite different from the desktop platform that you are using in your assertion, and even if opening a page (into a server/desktop environment) loads multiple requests, this will be detected by the netstat command.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.