mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-04-25 13:29:58 +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,
|
instantUpdates,
|
||||||
} = await this.config.getMany(['appUpdatePollInterval', '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
|
// We add a random jitter up to `maxApiJitterDelay` to
|
||||||
// the configured interval
|
// space out poll requests
|
||||||
let pollInterval = (0.5 + Math.random()) * appUpdatePollInterval;
|
let pollInterval =
|
||||||
|
Math.random() * constants.maxApiJitterDelay + appUpdatePollInterval;
|
||||||
|
|
||||||
if (instantUpdates || !isInitialCall) {
|
if (instantUpdates || !isInitialCall) {
|
||||||
try {
|
try {
|
||||||
|
@ -58,6 +58,10 @@ const constants = {
|
|||||||
supervisorNetworkGateway: '10.114.104.1',
|
supervisorNetworkGateway: '10.114.104.1',
|
||||||
// How often can we report our state to the server in ms
|
// How often can we report our state to the server in ms
|
||||||
maxReportFrequency: 10 * 1000,
|
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) {
|
if (process.env.DOCKER_HOST == null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user