bool ThriftServer::isOverloaded( const transport::THeader::StringToStringMap* readHeaders, const std::string* method) const { if (UNLIKELY(isOverloaded_ && isOverloaded_(readHeaders, method))) { return true; } uint32_t maxRequests = getMaxRequests(); if (maxRequests > 0) { return static_cast<uint32_t>(getActiveRequests()) >= maxRequests; } return false; }
bool ThriftServer::isOverloaded(uint32_t workerActiveRequests) { if (UNLIKELY(isOverloaded_())) { return true; } if (maxRequests_ > 0) { if (isUnevenLoad_) { return globalActiveRequests_ + getPendingCount() >= maxRequests_; } else { return workerActiveRequests >= maxRequests_ / nWorkers_; } } return false; }
bool ThriftServer::isOverloaded(uint32_t workerActiveRequests) { if (UNLIKELY(isOverloaded_())) { return true; } if (maxRequests_ > 0) { if (isUnevenLoad_) { int pendingRequests = 0; for (auto& worker: workers_) { pendingRequests += worker.worker->getPendingCount(); } return (globalActiveRequests_ + pendingRequests) >= maxRequests_; } else { return workerActiveRequests >= maxRequests_ / nWorkers_; } } return false; }