Affected: Ruby, Python SDK
Symptoms
Implementations of Ruby or Python SDKs with frameworks such as Rails or Flask may experience the following issues:
- SDK fetching stale data.
- SDK failing to send events back to LaunchDarkly servers.
Cause
The issue occurs due to the way Ruby and Python handle application forking. Forking creates new processes by copying the original process, including the initialized LaunchDarkly SDK. However, the SDK threads responsible for updating cached flag configurations and flushing events to LaunchDarkly servers do not get created when forking processes. This leads to:
- Stale cached data being used.
- Events not being sent back to LaunchDarkly.
Solution
To resolve the issue, follow these steps:
-
Detect inactive threads: Use the thread detection scripts to verify if threads are active in the forked process.
-
Reinitialize SDK: Confirm if threads are inactive.
- Instantiate a new LaunchDarkly client instance in each forked child process.
-
Address connectivity challenges: If scaling leads to connectivity issues, consider the following.
- OS limits: Ensure I/O connection limits are sufficient. These typically range between 1k–2k connections.
- Bandwidth limits: Avoid initializing all SDK instances simultaneously to prevent network bottlenecks.
-
Implement Relay Proxy for scalability: For a more robust solution, follow the steps below.
- Set up a Relay Proxy on the same server as your application.
- Configure application instances to connect to the Relay Proxy instead of directly to LaunchDarkly.
This reduces outgoing connections and avoids excessive streaming connections.