A web server running Apache on Linux is experiencing slow response times. The administrator runs 'netstat -tuln' and sees many connections in TIME_WAIT state. Which of the following is the best course of action to improve performance?
Trap 1: Increase the KeepAliveTimeout directive.
Raising KeepAliveTimeout holds each idle persistent connection open longer, so sockets linger and TIME_WAIT accumulates further rather than draining. It is tempting because it reduces TCP handshakes for chatty clients, and would suit a low-traffic site where connection setup overhead dominates latency.
Trap 2: Disable the KeepAlive directive.
Disabling KeepAlive forces a fresh TCP connection per request, multiplying the short-lived sockets that enter TIME_WAIT and worsening the backlog. It is tempting because it frees worker slots held by idle clients, and would suit a server with very few, widely spaced requests.
Trap 3: Increase the MaxKeepAliveRequests directive.
MaxKeepAliveRequests caps how many requests a single persistent connection may carry; raising it lengthens connection reuse but does not clear existing TIME_WAIT sockets. It is tempting because it tunes keep-alive behaviour, and would suit a busy server serving many requests per connection.
- A
Increase the KeepAliveTimeout directive.
Why it fails: Raising KeepAliveTimeout holds each idle persistent connection open longer, so sockets linger and TIME_WAIT accumulates further rather than draining. It is tempting because it reduces TCP handshakes for chatty clients, and would suit a low-traffic site where connection setup overhead dominates latency.
- B
Disable the KeepAlive directive.
Why it fails: Disabling KeepAlive forces a fresh TCP connection per request, multiplying the short-lived sockets that enter TIME_WAIT and worsening the backlog. It is tempting because it frees worker slots held by idle clients, and would suit a server with very few, widely spaced requests.
- C
Enable TCP keepalive and adjust kernel parameters for faster reuse.
Adjusting kernel parameters such as tcp_tw_reuse and enabling keepalive lets the system recycle TIME_WAIT sockets and detect dead peers faster. This satisfies the stem's performance constraint by reducing socket exhaustion and connection-handling overhead during high Apache traffic.
- D
Increase the MaxKeepAliveRequests directive.
Why it fails: MaxKeepAliveRequests caps how many requests a single persistent connection may carry; raising it lengthens connection reuse but does not clear existing TIME_WAIT sockets. It is tempting because it tunes keep-alive behaviour, and would suit a busy server serving many requests per connection.