We've experienced 502 (BAD GATEWAY) on load tests due to the following settings in Express:
const app = express();
const server = app.listen(port);
server.keepAliveTimeout = 61 * 1000;
server.headersTimeout = 65 * 1000;
I've changed them to
const app = express();
const server = app.listen(port);
server.keepAliveTimeout = 120 * 1000;
server.headersTimeout = 125 * 1000;
And ever since the 502 (BAD GATEWAY) disappeared.
What are the consequences and side effects of a large KeepAlive ,assuming that I plan to support more Users Per Second in the future (at the moment around 30 U/S) ?
handling each request takes time, so when you send a heavy load on your server, your server keep your requests in memory and process each request in queue so, when your sever process fast it could empty the queue and memory as soon as possible but when it takes time, request reach timeout so when you increase the time out your server when trying to empty queue and memory look at time out and if a timeout occurred send 5XX error, and answer to your question, increasing the value of timeout don't increase request per second of your server