You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/06/28 23:40:18 UTC

[GitHub] [pulsar-client-go] dvergnes opened a new pull request #557: [Issue 556]Add jitter to exponential backoff (#556)

dvergnes opened a new pull request #557:
URL: https://github.com/apache/pulsar-client-go/pull/557


   Fixes #556 
   
   
   ### Motivation
   When reconnecting to a broker, an exponential backoff strategy is used. However, there is no randomness involved which means in case of a general outage impacting several clients, they will try to reconnect at the same time.
   
   ### Modifications
   
   The modification consists of adding a jitter that adds 20% of delay after the delay is doubled on each retry.
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   This change added unit tests to verify the expected behavior.
   
   ### Does this pull request potentially affect one of the following parts:
   
   *If `yes` was chosen, please highlight the changes*
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API: no
     - The schema: no
     - The default values of configurations: no)
     - The wire protocol: no
   
   ### Documentation
   
     - Does this pull request introduce a new feature? no
     - If yes, how is the feature documented? not applicable
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a followup issue for adding the documentation
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] cckellogg commented on a change in pull request #557: [Issue 556]Add jitter to exponential backoff (#556)

Posted by GitBox <gi...@apache.org>.
cckellogg commented on a change in pull request #557:
URL: https://github.com/apache/pulsar-client-go/pull/557#discussion_r660194211



##########
File path: pulsar/internal/backoff.go
##########
@@ -40,6 +43,7 @@ func (b *Backoff) Next() time.Duration {
 	} else if b.backoff.Nanoseconds() > maxBackoff.Nanoseconds() {
 		b.backoff = maxBackoff
 	}
+	jitter := rand.Float64() * float64(b.backoff) * jitterPercentage

Review comment:
       Does the generator need to be seeded (https://golang.org/pkg/math/rand/#Seed)?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] dvergnes commented on a change in pull request #557: [Issue 556]Add jitter to exponential backoff (#556)

Posted by GitBox <gi...@apache.org>.
dvergnes commented on a change in pull request #557:
URL: https://github.com/apache/pulsar-client-go/pull/557#discussion_r660196553



##########
File path: pulsar/internal/backoff.go
##########
@@ -40,6 +43,7 @@ func (b *Backoff) Next() time.Duration {
 	} else if b.backoff.Nanoseconds() > maxBackoff.Nanoseconds() {
 		b.backoff = maxBackoff
 	}
+	jitter := rand.Float64() * float64(b.backoff) * jitterPercentage

Review comment:
       Yes, you are right. I updated the PR.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] wolfstudy merged pull request #557: [Issue 556]Add jitter to exponential backoff (#556)

Posted by GitBox <gi...@apache.org>.
wolfstudy merged pull request #557:
URL: https://github.com/apache/pulsar-client-go/pull/557


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] dvergnes commented on a change in pull request #557: [Issue 556]Add jitter to exponential backoff (#556)

Posted by GitBox <gi...@apache.org>.
dvergnes commented on a change in pull request #557:
URL: https://github.com/apache/pulsar-client-go/pull/557#discussion_r660196553



##########
File path: pulsar/internal/backoff.go
##########
@@ -40,6 +43,7 @@ func (b *Backoff) Next() time.Duration {
 	} else if b.backoff.Nanoseconds() > maxBackoff.Nanoseconds() {
 		b.backoff = maxBackoff
 	}
+	jitter := rand.Float64() * float64(b.backoff) * jitterPercentage

Review comment:
       Yes, you are right. I updated the PR.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] cckellogg commented on a change in pull request #557: [Issue 556]Add jitter to exponential backoff (#556)

Posted by GitBox <gi...@apache.org>.
cckellogg commented on a change in pull request #557:
URL: https://github.com/apache/pulsar-client-go/pull/557#discussion_r660194211



##########
File path: pulsar/internal/backoff.go
##########
@@ -40,6 +43,7 @@ func (b *Backoff) Next() time.Duration {
 	} else if b.backoff.Nanoseconds() > maxBackoff.Nanoseconds() {
 		b.backoff = maxBackoff
 	}
+	jitter := rand.Float64() * float64(b.backoff) * jitterPercentage

Review comment:
       Does the generator need to be seeded (https://golang.org/pkg/math/rand/#Seed)?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org