This topic explains the prerequisites you must consider when you’re setting up a LaunchDarkly SDK for the first time.
Regardless of which SDK you use, everyone who integrates LaunchDarkly with their code must consider the following prerequisites. Making decisions about the items listed below will help you use feature flags in a way that makes sense for your use case, customers, security considerations, and existing network architecture.
Consider the following factors when you’re starting to integrate LaunchDarkly SDKs with your code:
A context is a generalized way of referring to the people, services, machines, or other resources that encounter feature flags in your product. Contexts replace another data object in LaunchDarkly: “users.”
Creating contexts and evaluating flags based on them is supported in the latest major versions of most of our SDKs. For these SDKs, the code samples on this page include the two most recent versions.
Here are some basic guidelines for implementing LaunchDarkly SDKs:
The SDK types have different security considerations as well as some behavioral and architectural differences. They handle flag evaluations differently, utilize different kinds of SDK keys, and support different languages.
To learn more, read Choosing an SDK type.
The initial payload contains all the targeting rules for the environment associated with the provided SDK key. If you target a large number of individual contexts, have a very large number of flags, or have large numbers of extremely complicated rules, then this can increase the initial payload size. Configure any relevant timeout options to anticipate a large initial load. This helps prevent the SDK from timing out.
The SDK will time out if it cannot get a network connection to LaunchDarkly. Failure to connect is a recoverable error, so the SDK will keep trying to reconnect, but a timeout could happen in the middle of an attempt. If the SDK times out during a first-time initialization, it will serve the flag values you defined in your application code until it can connect to LaunchDarkly.
Your SDK should only initialize once statically, and that instance should be the exclusive instance you use for a given LaunchDarkly project. When you create multiple SDK instances, previous instances may leak into memory and stay active beyond their useful lifespan.
When you have enough of these instances running, they can cause bottlenecks in the connection to the streaming endpoint.