[gRPC-python] Any examples of using "fork" method of parallelism in gRPC-Python

31 views
Skip to first unread message

madha...@gmail.com

unread,
Sep 27, 2018, 12:48:05 AM9/27/18
to grpc.io
With the recent launch of grpc-python 1.15.0 version fork method has been enabled with GRPC_ENABLE_FORK_SUPPORT=1 flag, to achieve parallelism. Is there any tutorial/example explaining how to make use of it ? (We have been using single thread approach until now, as performance was degrading with multiple threads (owing to GIL). So desparately need the multi-process way of achieving parallelism in grpc-python.) Wondering how the request routing actually happens. From Master to the forked processes ?

Srini Polavarapu

unread,
Sep 27, 2018, 3:16:34 PM9/27/18
to grpc.io
The fork support added in 1.15.0 in gRPC-Python is only for the client side. This means, on a gRPC-Python client, it is now possible to fork the process while an RPC is in progress. Typically mulitprocessing module is used to distribute your work to child processes and get the result back. For example, you could be getting streamed responses from a server and handle the response in a child process without affecting the ongoing streaming RPC in the parent process. This was previously not supported. In this example, a datastore client forks using multiprocessing after it has created a gRPC connection and done an RPC. This didn't work prior to 1.15.0.
Reply all
Reply to author
Forward
0 new messages