mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-19 13:47:54 +00:00
Add a random offset to the poll interval with each poll
Change-type: patch Closes: #1242 Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
parent
a03e89caf8
commit
58c6a69e5a
@ -608,9 +608,10 @@ export class APIBinder {
|
||||
instantUpdates,
|
||||
} = await this.config.getMany(['appUpdatePollInterval', 'instantUpdates']);
|
||||
|
||||
// We add jitter to the poll interval so that it's between 0.5 and 1.5 times
|
||||
// the configured interval
|
||||
let pollInterval = (0.5 + Math.random()) * appUpdatePollInterval;
|
||||
// We add a random jitter up to `maxApiJitterDelay` to
|
||||
// space out poll requests
|
||||
let pollInterval =
|
||||
Math.random() * constants.maxApiJitterDelay + appUpdatePollInterval;
|
||||
|
||||
if (instantUpdates || !isInitialCall) {
|
||||
try {
|
||||
|
@ -58,6 +58,10 @@ const constants = {
|
||||
supervisorNetworkGateway: '10.114.104.1',
|
||||
// How often can we report our state to the server in ms
|
||||
maxReportFrequency: 10 * 1000,
|
||||
// How much of a jitter we can add to our api polling
|
||||
// (this number is used as an upper bound when generating
|
||||
// a random jitter)
|
||||
maxApiJitterDelay: 60 * 1000,
|
||||
};
|
||||
|
||||
if (process.env.DOCKER_HOST == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user