jb55 on Nostr: Managing subscriptions for potentially many apps is an interesting challenge: you ...
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.
Published at
2024-12-19 05:18:22 GMTEvent JSON
{
"id": "06c997f56a3bb3a8f4592c4d21955313bcaa2dafed278146eb77f11723c7b074",
"pubkey": "32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245",
"created_at": 1734585502,
"kind": 1,
"tags": [
[
"client",
"Damus Notedeck"
]
],
"content": "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.\n\nAn 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.\n\nFor example, two different apps register two different subscriptions:\n\n- appA: {\"authors\": [a, b]} for relay.damus.io\n- appB: {\"authors\": [a, c]} for relay.damus.io\n\nthe subscription manager will only create one subscription:\n\n- subManager: {\"authors\": [a, b, c]} for relay.damus.io\n\nanother optimization we're looking at is a bit more advanced. let's say you have:\n\n- appA: {\"kinds\": [1], \"limit\": 0}, {\"authors\": [a, b, c], \"limit\": 0} for relays.damus.io\n- appB: {\"limit\": 0} for relay.damus.io\n\nThe subscription manager would then replace all remote filters with a single one for that relay:\n\n- subManager: {\"limit\": 0} for relay.damus.io\n\nusing 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.\n\nLots of cool stuff happening behind the scenes to optimize things! Thanks for coming to my ted talk.",
"sig": "d10243abe3cc02316b4d0e1af819353b1b60bc1fae72a1668b6cba545964f4c8c51c223e978dc4e97c8a6831e6c7b27f5620e077d21fa639e7a7615e7fb0afe5"
}