Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a lot of CLOSE_WAIT in fbthrift server,How to fix it #610

Open
cankhn opened this issue Jul 18, 2024 · 0 comments
Open

a lot of CLOSE_WAIT in fbthrift server,How to fix it #610

cankhn opened this issue Jul 18, 2024 · 0 comments

Comments

@cankhn
Copy link

cankhn commented Jul 18, 2024

version 2022.10.10.00
server code

namespace apache {
namespace thrift {
template <typename T> class MyEvbAsyncProcessorFactory : public AsyncProcessorFactory {
  public:
    explicit MyEvbAsyncProcessorFactory(std::shared_ptr<T> t) { svIf_ = t; }

    std::unique_ptr<apache::thrift::AsyncProcessor> getProcessor() override
    {
        return std::unique_ptr<apache::thrift::AsyncProcessor>(new typename T::ProcessorType(svIf_.get()));
    }

    std::vector<ServiceHandlerBase*> getServiceHandlers() override { return {svIf_.get()}; }

    CreateMethodMetadataResult createMethodMetadata() override
    {
        WildcardMethodMetadataMap wildcardMap;
        wildcardMap.wildcardMetadata =
            std::make_shared<WildcardMethodMetadata>(AsyncProcessorFactory::MethodMetadata::ExecutorType::EVB);
        wildcardMap.knownMethods = {};

        return wildcardMap;
    }

  private:
    std::shared_ptr<T> svIf_;
};
}  // namespace thrift
}  // namespace apache

auto handler = std::make_shared<Handler>();
auto procFactory = std::make_shared<apache::thrift::MyEvbAsyncProcessorFactory<Handler>>(handler);
int ret = handler->init(*initParam_);
if (ret != 0) {
    std::cout << "handler init failed" << endl;
    return nullptr;
}
auto server = std::make_unique<ThriftServer>();
server->setPort(initParam_->common.port);
server->setProcessorFactory(procFactory);
server->setMaxConnections(param.common.maxConn);
server->setNumIOWorkerThreads(param.common.maxConn);
server->setNumCPUWorkerThreads(param.common.workerCount);
server->setIdleTimeout(std::chrono::milliseconds(0));
server->setConnectionAgeTimeout(std::chrono::milliseconds(0));
server->setStreamExpireTime(std::chrono::milliseconds(0));

[root@]# netstat -ae|grep "CLOSE_WAIT" | wc -l
897

@cankhn cankhn changed the title a lot of CLOSE_WAIT in fbthrift service,How to fix it a lot of CLOSE_WAIT in fbthrift server,How to fix it Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant