如何限制Go的grpc go例程号

Is there anyway that I can constrain the number of go routines in grpc client? I have a go application that uses grpc client and I found that there are quite a few amount of go routines being created and kept growing. Thanks for any help.

If your question is how to limit grpc goroutines, there is no way, but I doubt there is any point in limiting goroutine number. What if you reached your limit and another request come?

You could use a semaphore like pattern at the beginning of your handler so you limit to N concurrent requests. Additional requests will wait for other requests to finish before they start processing (But there is more that N goroutines, only N of them are working).

Here is an implementation of semaphores using channel.