Q28: What is HTTP Keep-Alive, and how do you configure connection pooling in Node.js?
HTTP Keep-Alive reuses established TCP sockets for multiple HTTP request/response cycles, eliminating repeated TCP three-way handshake and TLS negotiation latencies. In Node.js, enable socket pooling by passing keepAlive: true and configuring maxSockets and maxFreeSockets on http.Agent or https.Agent instances.
Key Takeaways
- Keep-Alive avoids establishing new TCP sockets on every outgoing HTTP request.
- Configured via
http.Agent({ keepAlive: true, maxSockets: 100 }).
Knowledge Check
Which parameter on http.Agent limits total parallel open connections permitted per origin host?