-
Notifications
You must be signed in to change notification settings - Fork 4.4k
optimize grpc settings #36528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
optimize grpc settings #36528
Changes from all commits
55cb276
e268dc3
0520967
0ca7bcb
c617972
4196239
3f59e83
1b785f9
8da691d
079b5d7
23a8609
e606e24
633cf93
811e0e2
9234046
f56221c
0b444e6
9f65988
ff2f13a
aec1d2a
16d93fa
82ce53a
4a5ddce
774ff13
600fed4
8853082
a5822ec
603bbf0
5659767
49c851b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -185,8 +185,20 @@ def start(self): | |||||||||||||||||||||
| try: | ||||||||||||||||||||||
| process, endpoint = self.start_process() | ||||||||||||||||||||||
| wait_secs = .1 | ||||||||||||||||||||||
| channel_options = [("grpc.max_receive_message_length", -1), | ||||||||||||||||||||||
| ("grpc.max_send_message_length", -1)] | ||||||||||||||||||||||
| channel_options = [ | ||||||||||||||||||||||
liferoad marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||
| ("grpc.max_receive_message_length", -1), | ||||||||||||||||||||||
| ("grpc.max_send_message_length", -1), | ||||||||||||||||||||||
| # Default: 20000ms (20s), increased to 10 minutes for stability | ||||||||||||||||||||||
| ("grpc.keepalive_timeout_ms", 600_000), | ||||||||||||||||||||||
| # Default: 2, set to 0 to allow unlimited pings without data | ||||||||||||||||||||||
| ("grpc.http2.max_pings_without_data", 0), | ||||||||||||||||||||||
| # Default: False, set to True to allow keepalive pings when no calls | ||||||||||||||||||||||
| ("grpc.keepalive_permit_without_calls", True), | ||||||||||||||||||||||
| # Default: 2, set to 0 to allow unlimited ping strikes | ||||||||||||||||||||||
| ("grpc.http2.max_ping_strikes", 0), | ||||||||||||||||||||||
liferoad marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||
| # Default: 0 (disabled), enable socket reuse for better handling | ||||||||||||||||||||||
| ("grpc.so_reuseport", 1), | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not going to do anything usefull unless you specifically bind multiple server listeners to the same port. See https://github.com/grpc/grpc/tree/master/examples/python/multiprocessing#calculating-prime-numbers-with-multiple-processes. This also can be useful when you want to bind a socket to a random (
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For prism runner, if the job_port pipeline option is not specified, its default value is 0: beam/sdks/python/apache_beam/options/pipeline_options.py Lines 1906 to 1908 in eba04b2
This port number is used by prism to call
Inside beam/sdks/python/apache_beam/utils/subprocess_server.py Lines 606 to 607 in eba04b2
This is exactly the case where this grpc option is useful.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great! With this option, you don't need to close the socket for the found port anymore, as you'll be able to bind and serve on it: beam/sdks/python/apache_beam/utils/subprocess_server.py Lines 610 to 612 in eba04b2
You'll need to bind the initial socket with
This approach addresses the race condition where an unused port was found by one process, closes the socket, but before this process starts listening on the found port, it's acquired by another process, resulting in By not closing the socket until the server stops listening, you'll prevent other processes from seeing that port as unused. Note that this only applies to systems where |
||||||||||||||||||||||
| ] | ||||||||||||||||||||||
| self._grpc_channel = grpc.insecure_channel( | ||||||||||||||||||||||
| endpoint, options=channel_options) | ||||||||||||||||||||||
| channel_ready = grpc.channel_ready_future(self._grpc_channel) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.