Hello Team! Thank you for the great model serving ...
# ask-for-help
u
Hello Team! Thank you for the great model serving framework! 😄 I have a question about using multiple workers (https://docs.bentoml.com/en/latest/build-with-bentoml/parallelize-requests.html#gpu-workloads) My bentoml server will have four workers. And Client send many requsets to bentoml simultaneously. I expected that all workers are busy for handling the requests. However, some workers do not anything while other workers are busy. Requests are not distributted to all workers evenly... Server code: @bentoml.service( resources={"gpu": torch.cuda.device_count(), "cpu": num_devices*30}, workers=4 ) ... @bentoml.api() def test(self, data) -> dict: worker_id = (bentoml.server_context.worker_index-1) print('Worker id is: ', worker_id, ' time: ', time.strftime('%Y.%m.%d - %H:%M:%S')) # Inference code here print('Worker End id is: ', worker_id, ' time: ', time.strftime('%Y.%m.%d - %H:%M:%S')) return body Log: Worker id is: 0 time: 2024.11.29 - 142435 Worker id is: 3 time: 2024.11.29 - 142435 Worker End id is: 0 time: 2024.11.29 - 142445 Worker id is: 0 time: 2024.11.29 - 142445 Worker End id is: 3 time: 2024.11.29 - 142445 Worker id is: 3 time: 2024.11.29 - 142445 Worker id is: 1 time: 2024.11.29 - 142435 Worker End id is: 1 time: 2024.11.29 - 142445 Worker id is: 2 time: 2024.11.29 - 142436 Worker End id is: 2 time: 2024.11.29 - 142446 Worker End id is: 0 time: 2024.11.29 - 142455 Worker End id is: 3 time: 2024.11.29 - 142455 My client sent many requests at once (at 142434). As you see, the order of worker to handler the request is : 0->3->*0*->3->1... worker #1, #2 is not allocated even if it is idle. On the other hand, worker#0 is re-allocated. Therefore, the third requests takes 2x times since it should wait until worker#0's previous request handling, and then handle the request. Therefore, this makes overall performance down.. Could you give me your valuable advice to resolve this issue?