What is the difference between grpc.WithConnectParams.Backoff and grpc_retry.WithBackoff?

1k views Asked by At

I am trying to understand what is the difference between two GRPC ways to do a retry.

One is grpc.WithConnectParams; that is, let's say

grpc.Dial(address, grpc.WithConnectParams(grpc.ConnectParams{
    Backoff: backoff.Config{
        BaseDelay: 1 * time.Second,
        Multiplier: 1.6,
        MaxDelay: 15*time.Second,
    }))

vs

grpc.Dial(address, []grpc_retry.CallOption{
    grpc_retry.WithMax(4),
    grpc_retry.WithBackoff(grpc_retry.BackoffExponential(1*time.Second)),
})

The first one is documented here

https://pkg.go.dev/google.golang.org/grpc/backoff

The other is documented here

https://pkg.go.dev/github.com/grpc-ecosystem/go-grpc-middleware/retry

They seem like doing the same thing...? I am not exactly sure

1

There are 1 answers

0
Karel Bílek On BEST ANSWER

grpc.WithConnectParams.Backoff does retries on the "low level" - the connection level; while grpc_retry.CallOption does retries on the request level.