From cebeda0e376dd7afd6729b2cd525e3c2373f27cd Mon Sep 17 00:00:00 2001 From: Matthew Little Date: Mon, 13 Sep 2021 23:32:19 +0200 Subject: [PATCH] fix: disable http keep-alive for stacks-node /v2 proxied endpoints --- src/api/routes/core-node-rpc-proxy.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/api/routes/core-node-rpc-proxy.ts b/src/api/routes/core-node-rpc-proxy.ts index 71f82781..092d31d2 100644 --- a/src/api/routes/core-node-rpc-proxy.ts +++ b/src/api/routes/core-node-rpc-proxy.ts @@ -25,9 +25,13 @@ export function createCoreNodeRpcProxyRouter(): express.Router { logger.info(`/v2/* proxying to: ${stacksNodeRpcEndpoint}`); + // Note: while keep-alive may result in some performance improvements with the stacks-node http server, + // it can also cause request distribution issues when proxying to a pool of stacks-nodes. See: + // https://github.com/blockstack/stacks-blockchain-api/issues/756 const httpAgent = new Agent({ - keepAlive: true, - keepAliveMsecs: 60000, + // keepAlive: true, + keepAlive: false, // `false` is the default -- set it explicitly for readability anyway. + // keepAliveMsecs: 60000, maxSockets: 200, maxTotalSockets: 400, });