Node.js · Middle · Question 73 of 75
Why does HTTP keep-alive matter for a service that calls other APIs a lot?
- ✓Correct answer: Reusing TCP (and TLS) connections avoids a new handshake for every request, which saves latency and CPU
- 2Keep-alive makes responses smaller
- 3Without keep-alive Node.js can send only one request per second
Explanation
The global fetch (undici) and the default http agent in modern Node.js reuse connections. Very high request rates may still need tuning of the connection pool.