Skip to content

Commit aec1d2a

Browse files
committed
more tunes on the grpc options
1 parent ff2f13a commit aec1d2a

File tree

2 files changed

+34
-17
lines changed

2 files changed

+34
-17
lines changed

sdks/python/apache_beam/runners/worker/channel_factory.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,24 @@
2323

2424
class GRPCChannelFactory(grpc.StreamStreamClientInterceptor):
2525
DEFAULT_OPTIONS = [
26-
("grpc.keepalive_time_ms",
27-
120000), # Increased to 120s to further reduce ping frequency
28-
("grpc.keepalive_timeout_ms", 300000),
29-
("grpc.http2.max_pings_without_data",
30-
0), # Allow unlimited pings without data
31-
("grpc.keepalive_permit_without_calls",
32-
True), # Allow keepalive pings when no calls
33-
("grpc.http2.min_recv_ping_interval_without_data_ms",
34-
300000), # 5 minutes
35-
("grpc.http2.min_sent_ping_interval_without_data_ms",
36-
60000), # Increased to 60s to be more conservative
26+
# Default: 30000ms (30s), increased to 180s to reduce ping frequency
27+
("grpc.keepalive_time_ms", 180000),
28+
# Default: 5000ms (5s), increased to 10 minutes for stability
29+
("grpc.keepalive_timeout_ms", 600000),
30+
# Default: 2, set to 0 to allow unlimited pings without data
31+
("grpc.http2.max_pings_without_data", 0),
32+
# Default: False, set to True to allow keepalive pings when no calls
33+
("grpc.keepalive_permit_without_calls", True),
34+
# Default: 300000ms (5min), increased to 10min for stability
35+
("grpc.http2.min_recv_ping_interval_without_data_ms", 600000),
36+
# Default: 300000ms (5min), increased to 120s for conservative pings
37+
("grpc.http2.min_sent_ping_interval_without_data_ms", 120000),
38+
# Default: 2, set to 0 to allow unlimited ping strikes
39+
("grpc.http2.max_ping_strikes", 0),
40+
# Default: 0 (disabled), enable socket reuse for better handling
41+
("grpc.so_reuseport", 1),
42+
# Default: 0 (disabled), set 30s TCP timeout for connection control
43+
("grpc.tcp_user_timeout_ms", 30000),
3744
]
3845

3946
def __init__(self):

sdks/python/apache_beam/utils/subprocess_server.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,24 @@ def start(self):
188188
channel_options = [
189189
("grpc.max_receive_message_length", -1),
190190
("grpc.max_send_message_length", -1),
191-
("grpc.keepalive_time_ms",
192-
120000), # Increased to 120s to further reduce ping frequency
193-
("grpc.keepalive_timeout_ms", 300000),
191+
# Default: 30000ms (30s), increased to 180s to reduce ping frequency
192+
("grpc.keepalive_time_ms", 180000),
193+
# Default: 5000ms (5s), increased to 10 minutes for stability
194+
("grpc.keepalive_timeout_ms", 600000),
195+
# Default: 2, set to 0 to allow unlimited pings without data
194196
("grpc.http2.max_pings_without_data", 0),
197+
# Default: False, set to True to allow keepalive pings when no calls
195198
("grpc.keepalive_permit_without_calls", True),
196-
("grpc.http2.min_recv_ping_interval_without_data_ms", 300000),
197-
("grpc.http2.min_sent_ping_interval_without_data_ms",
198-
60000), # Increased to 60s to be more conservative
199+
# Default: 300000ms (5min), increased to 10min for stability
200+
("grpc.http2.min_recv_ping_interval_without_data_ms", 600000),
201+
# Default: 300000ms (5min), increased to 120s for conservative pings
202+
("grpc.http2.min_sent_ping_interval_without_data_ms", 120000),
203+
# Default: 2, set to 0 to allow unlimited ping strikes
204+
("grpc.http2.max_ping_strikes", 0),
205+
# Default: 0 (disabled), enable socket reuse for better handling
206+
("grpc.so_reuseport", 1),
207+
# Default: 0 (disabled), set 30s TCP timeout for connection control
208+
("grpc.tcp_user_timeout_ms", 30000),
199209
]
200210
self._grpc_channel = grpc.insecure_channel(
201211
endpoint, options=channel_options)

0 commit comments

Comments
 (0)