Skip to content

Support configurable maxSockets for HTTP agents#260

Open
jackie-nooks wants to merge 1 commit intomixpanel:masterfrom
jackie-nooks:feat/max-sockets-config
Open

Support configurable maxSockets for HTTP agents#260
jackie-nooks wants to merge 1 commit intomixpanel:masterfrom
jackie-nooks:feat/max-sockets-config

Conversation

@jackie-nooks
Copy link
Copy Markdown

Summary

The SDK creates HTTP agents with keepAlive: true but uses the Node.js default maxSockets: Infinity. In high-throughput server environments, concurrent track() calls can open an unbounded number of TCP connections to Mixpanel's API, which can exhaust file descriptors or trigger rate limits.

This PR adds support for a maxSockets init config option that gets passed through to the underlying http.Agent / https.Agent. When not set, behavior is unchanged (defaults to Infinity).

Usage

var mixpanel = Mixpanel.init('token', { maxSockets: 10 });

Changes

  • lib/mixpanel-node.js: Read maxSockets from init config and pass to Agent constructors
  • test/send_request.js: Test verifying maxSockets is forwarded to the Agent
  • readme.md: Usage example

📝 Confab link

The SDK creates HTTP agents with keepAlive: true but uses the Node.js
default maxSockets: Infinity. In high-throughput server environments,
concurrent track() calls can open an unbounded number of TCP connections
to Mixpanel's API, which can exhaust file descriptors or trigger rate
limits.

This adds support for a maxSockets init config option that gets passed
through to the underlying http.Agent / https.Agent. When not set,
behavior is unchanged (defaults to Infinity).

Usage:
  var mixpanel = Mixpanel.init('token', { maxSockets: 10 });

Confab-Link: https://confab.nooks.in/sessions/e7243277-5942-4965-8abe-99b18914a204
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant