launchdarkly / node-server-sdk

LaunchDarkly Server-side SDK for Node
Other
79 stars 65 forks source link

Stateless connection approach for feature flags #253

Closed milkchocolate closed 2 years ago

milkchocolate commented 2 years ago

Hi team, I'm using LaunchDarkly for my projects, it's awesome. I have some questions about how the client connects to the server.

Why is the connection stateful? It adds complexities for using the sdk client. Is it possible to use stateless connection for reading feature flags from the server.

For a stateless connection approach, can I initialize the client just before I read a feature flag and then shut down the client right after I finish the reading?

image

https://docs.launchdarkly.com/sdk/server-side/node-js#getting-started Screenshot from the doc:

image
eli-darkly commented 2 years ago

If you haven't seen our docs page on client-side and server-side SDKs, that might help to clarify things. Like all of the server-side LaunchDarkly SDKs, the server-side Node SDK is designed mainly for use in a long-running application that will need to evaluate feature flags frequently for many different users. In such a context, it's highly desirable to not have to make a new network request just to evaluate one flag. Instead, the SDK downloads the full flag configuration data first and holds it internally, so that when you request flag values for various users, the flags can be evaluated entirely within the SDK. And since flag configurations can be changed at any time, it's also desirable to maintain a streaming connection so that changes can be pushed from LaunchDarkly to the SDK if and when they occur, rather than requiring lots of polling requests to find out if anything has changed.

I don't know the details of your use case, but if what I've said doesn't seem applicable, it might be that what you really want is the client-side Node SDK rather than the server-side one.

milkchocolate commented 2 years ago

Hi @eli-darkly, thanks for your reply 👍