As asked
Explain the TCP three-way handshake. What are the SYN, SYN-ACK, and ACK states, and what does it mean when you see a lot of connections in SYN_SENT or TIME_WAIT on a production server?
Sample answer outline
Strong answers explain the handshake sequence, then explain SYN_SENT as the client waiting for a SYN-ACK (many of these suggest the target is unreachable or dropping packets, pointing to a firewall or overloaded server). TIME_WAIT is the 2*MSL period after connection close to handle delayed packets; many TIME_WAIT connections on a server under high connection churn is normal but can exhaust ports. Solutions include SO_REUSEADDR, shorter TIME_WAIT via tcp_fin_timeout tuning, or connection pooling to reduce churn.
Expect these follow-ups
- What is the purpose of the TIME_WAIT state and what happens if you disable it with tcp_tw_reuse?
- How does connection pooling in a database driver reduce TIME_WAIT pressure on an application server?