Skip to content

Commit

Permalink
mainboilerplate: use a maximum-size connection flow control window
Browse files Browse the repository at this point in the history
Rely only on stream-level flow control, and allow a single broker
transport to multiplex LOTS of journals without a flow control deadlock,
even if some are not being actively read.
  • Loading branch information
jgraettinger committed Apr 18, 2024
1 parent 3da60fd commit d612fdc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mainboilerplate/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package mainboilerplate
import (
"context"
"fmt"
"math"
"time"

grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
Expand All @@ -23,6 +24,14 @@ func (c *AddressConfig) MustDial(ctx context.Context) *grpc.ClientConn {
var cc, err = grpc.DialContext(ctx,
c.Address.GRPCAddr(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
// A single Gazette broker frequently serves LOTS of Journals.
// Readers will start many concurrent reads of various journals,
// but may process them in arbitrary orders, which means a journal
// stream could be "readable" and have available stream-level flow control,
// but still not send data because the connection-level flow control window
// is filled. So, effectively disable connection-level flow control and use
// only stream-level flow control.
grpc.WithInitialConnWindowSize(math.MaxInt32),
grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"loadBalancingConfig": [{"%s":{}}]}`, pb.DispatcherGRPCBalancerName)),
// Use a tighter bound for the maximum back-off delay (default is 120s).
// TODO(johnny): Make this configurable?
Expand Down

0 comments on commit d612fdc

Please sign in to comment.