bent icon indicating copy to clipboard operation
bent copied to clipboard

Support keepAlive in Node.js implementation

Open vgrichina opened this issue 5 years ago • 3 comments

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.

vgrichina avatar Feb 12 '20 22:02 vgrichina

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 avatar Feb 12 '20 23:02 mikeal

@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.

frol avatar Feb 13 '20 15:02 frol

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 :-(

koalo avatar Mar 26 '21 10:03 koalo