Affected: All SDKs
Symptoms
When running an SDK, the following error appears:
Exceeded event queue capacity. Increase capacity to avoid dropping events.
Cause
LaunchDarkly SDKs are designed to queue analytics events generated by certain SDK methods and flush them to LaunchDarkly servers at a set interval. Each SDK has default values for the event queue capacity
and the flushInterval
, but these may vary depending on the SDK.
If events are generated faster than they can be flushed, the event queue exceeds its capacity. When this happens, the SDK logs an error and discards any events that exceed the limit.
Solution
Follow these steps to address this issue:
To address this issue, adjust the event queue configuration to align with your application’s event generation rate and network conditions. The following steps provide a general procedure, using the Node.js (server-side) v8.x SDK as an example:
-
Include the
LDOptions
interface when initializing the SDK:- The
LDOptions
interface contains configuration options, includingcapacity
andflushInterval
. For the Node.js (server-side) SDK, the default values are:-
capacity
: 10,000 events -
flushInterval
: 5 seconds
-
- These defaults may vary between SDKs. Refer to your SDK’s API documentation for the specific default values.
- The
-
Adjust the configuration values:
- Increase the
capacity
to accommodate the volume of events your application generates. - Decrease the
flushInterval
to ensure events are sent to the LaunchDarkly servers more frequently.
Here is an example of how to configure these options in the Node.js SDK:
import * as ld from '@launchdarkly/node-server-sdk';
const options: ld.LDOptions = {
capacity: 12000,
flushInterval: 4,
};
const client = ld.init('sdk-key-123abc', options); - Increase the
-
Test and monitor the configuration:
- Experiment with different values to find a balance between memory usage and event reliability.
- Avoid setting
capacity
to excessively high values, as this could increase memory consumption and potentially affect application performance.
-
Consider application-specific factors:
- Evaluate the frequency at which your application generates events and the typical payload size.
- Optimize your settings to match these requirements while considering your system’s memory and network constraints.
-
Monitor for improvements:
- After making these changes, monitor the application to ensure the adjustments effectively prevent dropped events without negatively affecting performance.