bent
bent copied to clipboard
Support keepAlive in Node.js implementation
Most Node.js services heavy in HTTP calls to same destination benefit a lot of having keepAlive
on by default, e.g. we had to do it passing agent
when using node-fetch
:
https://github.com/nearprotocol/nearlib/blob/master/src.ts/utils/web.ts#L24
Is there any way to enable keepAlive
when using bent
? Also wonder if there is any good reason to not use it by default.
You shouldn’t need to pass the agent in. Node.js Core batches concurrent requests together to optimize for keep-alive. The browser does the same.
You’d only need to manage your own agent if you wanted to hold the connection between requests instead of having them closed out when there’s less load.
@mikeal Our use-case involves, potentially, millions requests to the same RPC host, and we run out of the number of TCP ports without Keep-Alive.
We also need to keep the connection alive between the requests. So we probably need to invest the effort to migrate to another library instead of bent :-(