You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is well known that the balance between max_workers and maximum_concurrent_rpcs, and number of pods/servers can be tricky. One important way to measure how this balance is doing, is by monitoring the work queue size in the thread pool. It would be a great addition to this lib.
I have hacked my way around it to do it for my use case, and I'm open to contribute here. What do you think? Follows the rough sketch of the code:
classThreadPoolQueueMetricServerInterceptor(PromServerInterceptor):
"""This interceptor measures the size of the work queue in the gRPC server thread pool, by the end of an execution. """
...
def_measure_queue_size(self):
# From the current thread, find its thread pool, and fetch its current queue size.thread=current_thread()
# A thread has target arguments as follows. We get the work queue.# executor_reference, work_queue, initializer, initargs_, work_queue, _, _=thread._argsself.queue_size_gauge.set(work_queue.qsize())
defintercept_service(self, continuation, handler_call_details):
defwrapper(behavior_fn, *args):
defnew_behavior(request, context):
# Call original behaviourresponse_or_iterator=behavior_fn(request, context)
self._measure_queue_size()
returnresponse_or_iteratorreturnnew_behaviorreturnself._wrap_rpc_behavior(continuation(handler_call_details), wrapper)
The text was updated successfully, but these errors were encountered:
Hi!
First, thanks for the contribution so far.
It is well known that the balance between
max_workers
andmaximum_concurrent_rpcs
, and number of pods/servers can be tricky. One important way to measure how this balance is doing, is by monitoring the work queue size in the thread pool. It would be a great addition to this lib.I have hacked my way around it to do it for my use case, and I'm open to contribute here. What do you think? Follows the rough sketch of the code:
The text was updated successfully, but these errors were encountered: