RelationalAI/rai-sdk-javascript

SDK polling interval should use exponential backoff

Opened this issue · 1 comments

It's currently hard-coded at 3 seconds which is too long for short queries:

interval = 3 * 1000, // 3 seconds

For example, the following 3 queries all report a time of 4.5 seconds in the console (1.5 seconds to return from the fast-path + 3 seconds until the next poll):

def insert:x = 2 * range[1,100 * 1000000,1]
def insert:x = 2 * range[1,200 * 1000000,1]
def insert:x = 2 * range[1,400 * 1000000,1]

But this one took 10.5 seconds (two more polling periods):

def insert:x = 2 * range[1,800 * 1000000,1]

We should instead use an exponential backoff for the polling period, similar to what we do in Julia:
https://github.com/RelationalAI/rai-sdk-julia/blob/935d4f1fe50e675ee462e290a0d3301a2d66d0a0/src/api.jl#L408-L419

Or, even better, Todd has suggested that we should set a much smaller exponent, based on the amount of time we've waited so far, rather than based on the time we slept for last. This is probably a better design, but might be a bit more work:
https://github.com/RelationalAI/rai-sdk-issues/issues/58

Note: This issue has been migrated to https://relationalai.atlassian.net/browse/RAI-6270.

This link is only accessible to employees of RelationalAI.