Skip to content

Commit d14989c

Browse files
committed
Improve grpc server settings
1 parent 768e538 commit d14989c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# vNext
22

3+
# v1.4.5
4+
5+
- (improvement) Improve grpc server settings
6+
37
# v1.4.4
48

59
- (bug) Fix integration of Lifecycle and health

grpc/grpc.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ func New(lifecycle *app.Lifecycle, logger golog.Logger) *grpc.Server {
2828
}
2929

3030
keepaliveOptions := grpc.KeepaliveParams(keepalive.ServerParameters{
31-
Time: time.Minute,
32-
Timeout: 3 * time.Second,
31+
Time: time.Minute,
32+
Timeout: 3 * time.Second,
33+
MaxConnectionIdle: 15 * time.Minute, // Close idle connections after 15 minutes
34+
MaxConnectionAge: 30 * time.Minute, // Force connection refresh after 30 minutes
3335
})
3436

3537
keepaliveEnforcementOptions := grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{
@@ -40,6 +42,11 @@ func New(lifecycle *app.Lifecycle, logger golog.Logger) *grpc.Server {
4042
server := grpc.NewServer(
4143
keepaliveOptions,
4244
keepaliveEnforcementOptions,
45+
grpc.InitialWindowSize(1024*1024), // 1MB initial window size
46+
grpc.InitialConnWindowSize(1024*1024), // 1MB initial connection window size
47+
grpc.MaxRecvMsgSize(16*1024*1024), // 16MB max receive message size
48+
grpc.MaxSendMsgSize(16*1024*1024), // 16MB max send message size
49+
grpc.MaxConcurrentStreams(1000),
4350
)
4451

4552
lifecycle.OnStart(func(ctx context.Context) error {

0 commit comments

Comments
 (0)