mixpanel / mixpanel-node

A node.js API for mixpanel
http://www.mixpanel.com
MIT License
477 stars 159 forks source link

Default use keepAlive agent for sdk #198

Closed hans-lizihan closed 2 years ago

hans-lizihan commented 2 years ago

by default nodejs http module will establish new TCP connection to server with

  1. dns resolution -> getaddr call in system
  2. make tcp handshake connection
  3. use that socket for communication

current implementation without agent results in lots of ENOTFOUND getaddr error in the dns module internally used by node.js due to the limitations of file descriptor in OS level. (this happens only if end user sends lots of request concurrently like use-cases of bulk import / high concurrency endpoints used in node.js servers).

using keepAlive agent should be a common practice in node.js sdks.

reference: https://github.com/stripe/stripe-node/blob/master/lib/net/NodeHttpClient.js#L8-L9 https://rakshanshetty.in/nodejs-http-keep-alive/

related PR: https://github.com/mixpanel/mixpanel-node/pull/185

wille commented 2 years ago

Get this merged!

tdumitrescu commented 2 years ago

Published in v0.15.0, thanks.