PSync Design » History » Version 3
Suravi Regmi, 11/25/2025 09:08 PM
| 1 | 1 | Suravi Regmi | # PSync Design |
|---|---|---|---|
| 2 | 2 | Suravi Regmi | |
| 3 | 1 | Suravi Regmi | |
| 4 | 3 | Suravi Regmi | ## Introduction |
| 5 | PSync is used to sync stream names and their sequence numbers across applications on a network. Partial sync, where consumers and data generators are separate entities, uses separate **“hello”** and **“sync”** protocols to facilitate this synchronization. |
||
| 6 | 1 | Suravi Regmi | |
| 7 | 3 | Suravi Regmi | --- |
| 8 | 1 | Suravi Regmi | |
| 9 | 3 | Suravi Regmi | ## Old PSync Implementation |
| 10 | 1 | Suravi Regmi | |
| 11 | 3 | Suravi Regmi | ### Old Hello Protocol |
| 12 | The hello protocol is used to communicate the producer’s state (a list of streams with sequence numbers) in raw and encoded (IBF) forms. Consumers send Interests for``` /<sync-prefix>/hello``` . The response from the network is: |
||
| 13 | **Name:** |
||
| 14 | ``` |
||
| 15 | /<sync-prefix>/hello/<latest-producer-IBF> |
||
| 16 | ``` |
||
| 17 | **Data:** |
||
| 18 | ``` |
||
| 19 | /<stream-name>/<sequence-number> |
||
| 20 | /<stream-name>/<sequence-number> |
||
| 21 | ... |
||
| 22 | /<stream-name>/<sequence-number> |
||
| 23 | ``` |
||
| 24 | The application can then choose which streams to add to their subscription list. |
||
| 25 | |||
| 26 | |||
| 27 | ### Old Sync Protocol |
||
| 28 | The **“sync”** protocol is then used to notify consumers when the producer has increased a sequence number for a stream that they are subscribed to. Consumers send Interests for ``` /<sync-prefix>/sync/<SL>/<old-IBF>/``` where ``` <SL>``` is the list of streams the consumer wants to subscribe to. The producer will calculate the difference between ```<old-IBF> ``` and its current IBF in the form of streams and sequence numbers.If there is a difference (consumer is out of sync with the producer) then the producer will respond with this Data: |
||
| 29 | **Name** |
||
| 30 | ``` |
||
| 31 | /<sync-prefix>/sync/<SL>/<old-IBF>/<new-IBF> |
||
| 32 | ``` |
||
| 33 | **Data** |
||
| 34 | ``` |
||
| 35 | /<stream-name>/<sequence-number> |
||
| 36 | /<stream-name>/<sequence-number> |
||
| 37 | ``` |
||
| 38 | ### Problems |
||
| 39 | |||
| 40 | **Hello Data Names are not Unique** |
||
| 41 | Hello data will change when a producer adds, updates, or removes a stream, but the data name does not change. Implementation details may be changed to prevent a consumer fetching old data, but it does not follow good design principles. |
||
| 42 | |||
| 43 | **Consumers are not Notified of Changes to Available Streams** |
||
| 44 | When the producer adds or removes a stream, consumers’ only mechanism for knowing of this update is through the Hello protocol. However, regularly sending Hello interests will render the sync protocol redundant, as sync data is always a subset of hello data. |
||
| 45 | |||
| 46 | * Hello requests used static names -> consumers got cached/outdated lists |
||
| 47 | * No automatic stream change notification |
||
| 48 | * User missed new data stream because it wasn't dynamically advertised |
||
| 49 | * Frequent polling defeated Sync's purpose |
||
| 50 | |||
| 51 | --- |
||
| 52 | |||
| 53 | ## New PSync Implementation |
||
| 54 | |||
| 55 | To solve these problems, we propose integrating the hello protocol into the sync protocol as a data stream, named ```/<prefix>/DEFAULT``` , as the consumer is subscribed to it by default. The sync protocol has mechanisms for |
||
| 56 | • unique names for data streams |
||
| 57 | • notification of updates to data streams |
||
| 58 | • communication of producer IBF |
||
| 59 | which satisfy our needs. |
||
| 60 | Data for the default stream will consist of a list of available streams. Its data name will be``` /<prefix>/DEFAULT/<sequence-number>``` where the sequence number is increased by 1 any time a stream is added or removed. Updates to this sequence number will be synced with consumers via the sync protocol. |
||
| 61 | |||
| 62 | |||
| 63 | ### Summary of New Protocol |
||
| 64 | |||
| 65 | * Combining Hello Protocol and Sync Protocol |
||
| 66 | * Add a default stream: ```<producer-prefix>/DEFAULT/<seq>``` |
||
| 67 | * Consumers are always subscribed to it. |
||
| 68 | * Producer publishes stream updates (add/remove) to this stream. |
||
| 69 | * Default stream seq number updates after each change. |
||
| 70 | * Sync protocol delivers these updates like any other update. |
||
| 71 | |||
| 72 | 2 | Suravi Regmi | |
| 73 | 1 | Suravi Regmi |  |