TransWikia.com

grpc python measure response time

Stack Overflow Asked by user3599803 on December 20, 2020

How can I measure the full time grpc-python takes to handle a request?
So far the best I can do is:

def Run(self, request, context):
   start = time.time()
   # service code...
   end = time.time()
   return myservice_stub.Response()

But this doesn’t measure how much time grpc takes to serialize the request, response, to transfer it over the network.. and so on. I’m looking for a way to "hook" into these steps.

One Answer

You can measure on the client side:

start = time.time()
response = stub.Run(request)
total_end_to_end = time.time() - start

Then you can get the total overhead (serialization, transfer) by reducing the computation of the Run method.

To automate the process, you can add (at least for the sake of the test) the computation time as a field to the myservice_stub.Response.

Answered by Mark Loyman on December 20, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP