Managing subscriptions for potentially many apps is an interesting challenge: you quickly run into subscription limits on relays if you do it in a naive way.

An approach we're taking in notedeck is via a global "subscription manager" that all apps can share: it can identify redundancy in all of the active filters and replace potentially hundreds of queries with a single query across many apps.

For example, two different apps register two different subscriptions:

- appA: {"authors": [a, b]} for relay.damus.io

- appB: {"authors": [a, c]} for relay.damus.io

the subscription manager will only create one subscription:

- subManager: {"authors": [a, b, c]} for relay.damus.io

another optimization we're looking at is a bit more advanced. let's say you have:

- appA: {"kinds": [1], "limit": 0}, {"authors": [a, b, c], "limit": 0} for relays.damus.io

- appB: {"limit": 0} for relay.damus.io

The subscription manager would then replace all remote filters with a single one for that relay:

- subManager: {"limit": 0} for relay.damus.io

using a filter subset algorithm I described on here before. This works because app widgets only have to think about local subscriptions in the local relay model, and the subscription manager's job is to optimize and merge remote filters.

Lots of cool stuff happening behind the scenes to optimize things! Thanks for coming to my ted talk.

Reply to this note

Please Login to reply.

Discussion

Great thunkin’ here nostr:npub1xtscya34g58tk0z605fvr788k263gsu6cy9x0mhnm87echrgufzsevkk5s . When you’re saying “apps” are you referring to multiple locally-installed mobile apps, like Damus and Primal? As in, they could have a common service that they each subscribe to which performs the webhookin’?

Or are you referring to “apps” as each one of the “decks” in NoteDeck perhaps?

Either way, that’s essentially WebSocket multiplexing with a Nostr event router to the proper “app” subscribers, am I right?

Jeez, the project is actually cooler than I thought. Ok, this is some pretty exciting stuff. I really like the direction this is going.

So foreseeably, I or my team could whip up an app and install it into NoteDeck? How cool is that?!

And I definitely see the logic behind having a WebSocket multiplexer at the “browser” level. So NoteDeck would expose some APIs, kinda like the window object in a trad-brow, and our apps would connect to a relay pool through it, gaining all of the advantages. Very cool.

I’m stoked to see how this keeps cookin’ up!

I haven’t looked at the underlying mechanisms of relays much yet. Would it make sense to build a dedicated “relay manager” relay that allowed any number of apps to connect to it and then it “deduped” these requests?

definitely!

But i feel like the application should be choosing which relays to target for different types of queries, which is a part of the subscription manager api… that would be lost on a relay

But what if one app wants refreshed every 10 minutes but another one every 24 hours

Not an issue?

What do you mean refreshed here? Subscriptions are always realtime