unleash
unleash copied to clipboard
feat: Real-time push for feature toggle changes (Stream)
I see from https://github.com/Unleash/unleash-client-node/blob/master/src/repository.ts that the toggles are synced between the server and the client via a polling strategy.
Any chance to take this to the next level by implementing a Duplex stream to push the feature toggles in real-time to all connected clients when the toggle is updated?
LaunchDarkly uses SSE for instance, https://launchdarkly.com/how-it-works/
The current implementation does use cache-headers so the toggles are not actually transferred if there are no changes (just a empty 304 response). So the cost on the network is minimal. Clients can also reuse exiting connections. If clients are polling every 15s a change will on average take 7.5s to take effect, and 15s in worst case.
Any chance to take this to the next level by implementing a Duplex stream to push the feature toggles in real-time to all connected clients when the toggle is updated?
We have discussed this previously, and it is for sure an interesting idea. The biggest benefit in my opinion is that metrics can be more "real time"-ish.
Some things we need to figure out:
- How will it affect client SDK complexity?
- How will SSE affect cache-ability (with proxies in between)?
- How will HTTP/2 affect this picture?
- Performance. (E.g. how often should clients send metrics?)
I also think that #381 could be a perfect fit, where clients can register which project they subscribe on, and get all updates related to those
How will it affect client SDK complexity?
I believe this will mean a change on the SDK to accommodate different types of transport:
- PollingTransport
- StreamingTransport
It’s also similarly implemented in launchdarkly’s node client: https://github.com/launchdarkly/node-client/blob/master/index.js#L96
What’s ClientInstanceStore for?
I’m guessing implementation wise on the Unleash server would include adding a ConnectionStore, which will hold a list of connection objects and listen to events on the EventStore.
The ConnectionStore should then propagate the updates to all connected clients via SSE.
This would be a huge benefit for use on mobile clients; having users' smartphones polling for UI/UX toggles could be a bit of a battery destroyer, but it's an extremely valuable concept for us, especially if we can mitigate continued issues during an outage by disabling buttons on the user's end.
What about this feature? is it planned?
Is this Streaming Solution in plan ? Is there any active work happening in regard to this ? This approach look more scalable and reduce single point of failure for the clients.
I have created a experiment branch for this. There is still a lot to consider, but seems like LISTEN/NOTIFY from postgres is a great start: https://github.com/Unleash/unleash/tree/poc/events
As it looks like this feature is still not available, what is the best alternative? .. is our only option to use webhooks to get informed about toggle changes? @ivarconr @geekyme
Unleash currently do not support streaming updates. We have some plans in the future for this, but for now will close this issue as it does not contribute more to our internal discussions.