0

I'd like to calculate PubNub publish latencies for PubNub clients before they actually begin publishing. Is there a preferred way to to this for PubNub?

To make my use case more clear, Im trying to synchronize clients, and these clients do not need to be synchronized at a wall-clock time, since they could be global. Hence this solution, wouldnt be necessary in my case (but it did point me in the right direction)

So I could still obtain a per-client latency calculation based on the above link, but that's for fetching the timestoken using the Time API. This was relevant for the above use-case which depended on clients syncing to a particular wall-clock time, hence a time-token was anyways required to be fetched

However in my case I dont need a timetoken. All clients can be synced using a simple wait for (k - latency) interval where k is a constant for all clients .

Therefore while I can use the timetoken method of calculating latency, I would prefer to know the actual publish latencies (unless there is no vast difference between the two)

7hacker
  • 1,928
  • 3
  • 19
  • 32
  • Not sure this is completely predictable expect that you can expect on average that it would be about a certain value as network conditions (mostly outside of PubNub's control) would not be constant. Can you provide some details about your use case and the sort of precision you require and over the period of time you would require this level of accuracy? – Craig Conover Feb 08 '16 at 21:12
  • Hi Craig, I dont require a high-degree of precision but i do want to be able to synchronize all clients to begin publishing at about the same time, anyhow i do think i have a solution which I have written up below, do let me know if there are any serious concerns with that – 7hacker Feb 08 '16 at 21:37

1 Answers1

1

Here are some steps I worked out myself to determine latency for publish

  1. determine the local time (in milliseconds): start = now()
  2. Client sends out a message with payload[ {"Type" = "latencyCheck"}, {"me" = "MyPubNubUUID" }]
  3. When Client receives message of the above signature with its own Id, it sets another variable end = now()
  4. latency to send a message and receive it yourself was : end - start
7hacker
  • 1,928
  • 3
  • 19
  • 32
  • Just know that this will vary over time but you should expect < 250 ms latency on the high end. I am asking others at PubNub to review for optimal algorithm. – Craig Conover Feb 08 '16 at 22:04
  • This will only determine the **`client`** latency. This won't measure PubNub DSN. – Stephen Blum Feb 08 '16 at 22:12
  • I am interested in measuring client latency. in short Im trying to do exactly this same thing https://www.pubnub.com/knowledge-base/discussion/195/how-do-i-synchronize-multiple-devices#latest , except that since i dont care about starting wall-clock time I dont think I need to fetch the timetoken via time API. But since Im still interested in measuring client latency I thought measuring client Publish Latency would be more apt for my use case. – 7hacker Feb 08 '16 at 22:38