Yes, it is elastic. It will dial the number of threads down to 1 thread (to be more precise, it will dial down to whatever is set in the ServerBuilder::SyncServerOption::MIN_POLLERS setting - which is "1" by default. Also, this is a "per-completion" queue setting)
thanks, -Sree On Mon, Sep 11, 2017 at 2:46 PM, Anirudh Kasturi <[email protected]> wrote: > Hi Sree it worked. So one more question. I believe there is a timeout > for the worker threads. In case there are more requests coming in and the > grpc server spins up new worker threads from the pool based on the incoming > requests, once those requests are processed, would the grpc server spin > them down back again? Is it that elastic? > > Thanks, > Anirudh > > On Mon, Sep 11, 2017 at 1:24 PM, Anirudh Kasturi <[email protected]> > wrote: > >> Thanks a lot Sree. This is very helpful. I will also make sure I >> upgrade my grpc version. >> >> Best, >> Anirudh >> >> On Mon, Sep 11, 2017 at 12:15 PM, Sree Kuchibhotla <[email protected]> >> wrote: >> >>> Hi Anirudh, >>> There is no direct way of reducing the number of worker threads. Btw, I >>> am assuming you are using gRPC version earlier than the latest 1.6. >>> >>> If so, when you are using a Synchronous grpc server, it by default >>> creates as many "completion queues" as the number of cores (In the latest >>> version of grpc, we only create ONE completion queue). >>> Each completion queue will have "atleast one" worker thread polling for >>> incoming new RPCs (i.e If a worker thread is busy handling an RPC it just >>> received, we create a new worker thread to poll for new RPCs. So clearly, >>> on a server that handles multiple RPCs in parallel, the number of worker >>> threads at any point may be greater than 1). >>> >>> >>> In anycase, you can reduce the "minimum number of workers" to 1 by >>> having the Sync server create only one completion queue the following way: >>> >>> ServerBuilder builder >>> ... >>> builder.SetSyncServerOption(ServerBuilder::SyncServerOption::NUM_CQS, 1) >>> >>> >>> (Here >>> <https://github.com/grpc/grpc/blob/b6ef6e9ff5701d15a352f38a450de2af49d19657/test/cpp/end2end/end2end_test.cc#L265> >>> is an example of a grpc test that sets the number of completion queues to >>> 4) >>> >>> thanks, >>> Sree >>> >>> On Mon, Sep 11, 2017 at 11:35 AM, Anirudh Kasturi < >>> [email protected]> wrote: >>> >>>> Hello folks, >>>> >>>> I noticed that when I bring up my grpc server, it spins up worker >>>> threads using the grpc::ThreadManager::WorkerThread::Run(). >>>> The number of worker threads spun = Number of Cores on the server I >>>> bring up my GRPC server on. >>>> >>>> For eg : If I have a VM with 2 cores, the grpc server brings up two >>>> worker threads. If the VM has 40 cores it brings up 40 worker threads. >>>> In reality, I just need one worker thread. Is it possible to bring up >>>> only one worker thread? Is that configurable? Also is there a way I can >>>> name the thread so that we have a way to track it? Thank you. >>>> >>>> Best, >>>> Anirudh >>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "grpc.io" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> To post to this group, send email to [email protected]. >>>> Visit this group at https://groups.google.com/group/grpc-io. >>>> To view this discussion on the web visit https://groups.google.com/d/ms >>>> gid/grpc-io/c744a0c7-c248-4a16-9bf1-df7fba045fe0%40googlegroups.com >>>> <https://groups.google.com/d/msgid/grpc-io/c744a0c7-c248-4a16-9bf1-df7fba045fe0%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> >> > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/grpc-io. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CALRi9QegsOz-DZMLdSx-DmKSiktvQTUFe8SCeX5J5ZDQfGtuMA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
