mcrouter
mcrouter copied to clipboard
McServerThreads without listening sockets
Hi community,
I am reading mcrouter code, and pretty puzzled about what McServerThreads without listening sockets do exactly. I am assuming remote thread mode (--remote-thread set to true)
From my understanding (might be wrong), McServerThreads with listening socket (AsyncServerSocket) will generate a AsyncSocket per connection from clients, and each McServerThread will have multiple AsyncSockets monitored. Once there is any request from certain AsyncSocket, the corresponding McServerThread will push the request with context and reply func to the messageQueue, while the Proxy thread will pull the messageQueue periodically.
Then the question comes: what does McServerThreads without listening sockets do exactly?
threadsSpawnController_ = std::make_unique<McServerThreadSpawnController>(
opts_.numListeningSockets);
size_t id;
// First construct the McServerThreads with listening sockets.
for (id = 0; id < opts_.numListeningSockets; id++) {
threads_.emplace_back(std::make_unique<McServerThread>(
McServerThread::Acceptor,
*this,
/*id*/ id,
(opts_.numListeningSockets > 1)));
}
// Now the rest
for (; id < opts_.numThreads; ++id) {
threads_.emplace_back(std::make_unique<McServerThread>(*this, id));
}
In the above code snippet from AsyncMcServer.cpp, opts_.numListeningSockets is specified by --num-listening-sockets, opts_.numThreads is mcrouterOpts.num_proxies specified by --num-proxies. If I specify --num-proxies to 16 and --num-listening-sockets to 2, what does the remaining 14 McServerThreads do? I guess they cannot accepted connections from clients and forward request to proxy.
Any comments or suggestions are highly appreciated!
Best, Yang