-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[openhabcloud] Tuning of reconnection parameters #12121
Comments
I think it's a good idea to add some kind of configuration option there. I am running 2 instances, one of those I want to reconnect as fast as possible (probably even faster than what is currently "allowed" if I could) and another instance which could very much stay offline for a long time. If there is an option to configure the "need" for reconnection (something simple like a number between 1 and 10 would be enough) then I would set one of the instances to 1 and the other one to 10. With a default of 5 that would allow users who would otherwise build their own version with lower (potentially too low) delays to decrease it and others who have instances just for testing or whatever can increase it so they don't put any unnecessary load on the system. So maybe make |
Best practices of different delay strategies discussed in https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/ |
@digitaldan how would you adjust the parameters for more graceful behaviour to cloud? Just as a suggestion to increase randomness, e.g. Delay would be as follows:
|
See #14251 |
As discussed in community forums with @digitaldan
To my knowledge, currently the cloud connector re-connects based on two different logic
Both of the places uses exponential backoff and random jitter to distribute the reconnects.
Parameters are as follows
IO.socket reconnects (case 1):
https://github.com/socketio/socket.io-client-java/blob/89ef9d09cee799ffb85e0252bcaf1993f9d49af9/src/main/java/io/socket/client/Manager.java#L146-L149
Cloud client reconnects, manually set (case 2):
The delay is calculated as follows
https://github.com/socketio/socket.io-client-java/blob/89ef9d09cee799ffb85e0252bcaf1993f9d49af9/src/main/java/io/socket/backo/Backoff.java#L16-L27
Distilling that code we get:
where
rand
is random term in range 0...1.There is a 50%/50% to have positive/negative jitter term.
In other words,
So
delay
is between ( 1 - JITTER ) * MIN * FACTOR ** attempts ... ( 1 + JITTER ) * MIN * FACTOR ** attempts. In addition, currently the code caps the delay to 5000 ms so that means that on 5th connection attempt, the delay is constant.Resulting in (*)
Could we optimize the parameters for more graceful interaction with cloud when all/many clients are disconnected at the same time? I am not sure which one of the reconnect logics (CloudClient vs IO.socket) kicks in these cases to be honest.
We could increase the randomness by increasing
jitter
. We could also increase base delaymin
...cc @digitaldan
(*)
The text was updated successfully, but these errors were encountered: