unleash icon indicating copy to clipboard operation
unleash copied to clipboard

feat: Real-time push for feature toggle changes (Stream)

Open geekyme opened this issue 5 years ago • 8 comments

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/

geekyme avatar Jan 28 '19 02:01 geekyme

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

ivarconr avatar Jan 28 '19 07:01 ivarconr

How will it affect client SDK complexity?

I believe this will mean a change on the SDK to accommodate different types of transport:

  1. PollingTransport
  2. StreamingTransport

It’s also similarly implemented in launchdarkly’s node client: https://github.com/launchdarkly/node-client/blob/master/index.js#L96

geekyme avatar Jan 29 '19 00:01 geekyme

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.

geekyme avatar Jan 29 '19 01:01 geekyme

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.

kjdelisle avatar Mar 18 '19 14:03 kjdelisle

What about this feature? is it planned?

jerry2007 avatar Jan 30 '20 09:01 jerry2007

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.

rishi-pratap avatar Mar 24 '20 10:03 rishi-pratap

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

ivarconr avatar Oct 30 '20 15:10 ivarconr

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

sirAlexander avatar Feb 17 '22 09:02 sirAlexander

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.

ivarconr avatar Nov 09 '22 22:11 ivarconr