apache / rocketmq-client-cpp

Apache RocketMQ cpp client
https://rocketmq.apache.org/
Apache License 2.0
366 stars 158 forks source link

Threads pool improvement #301

Closed he1016060110 closed 3 years ago

he1016060110 commented 4 years ago

FEATURE REQUEST Recently I'm writing a grpc rocketmq proxy server because php/nodejs are the main languages in our company and we cannot use this sdk directly. I found out that this sdk will create more than 10 threads for every produce/consume client.They include at least one ConsumeTP, 4 NetworkTP and several timer thread. If I initiate multiple consumer client, I get hundreds of threads in one process,which is a disaster. I hope that there are threads pools for all the clients.NetworkTP and the timer threads can be used by all clients.It's more efficient.

ifplusor commented 4 years ago

ConsumeTP and some timer belong to Consumer, and NetworkTP and others belong to MQClientFactory. if you create all Consumer with same instance name, MQClientFactory will be reuse. Number of ConsumeTP can be set by Consumer. If you SDK in different process, it is useless.

he1016060110 commented 4 years ago

ConsumeTP and some timer belong to Consumer, and NetworkTP and others belong to MQClientFactory. if you create all Consumer with same instance name, MQClientFactory will be reuse. Number of ConsumeTP can be set by Consumer. If you SDK in different process, it is useless.

thanks,NetworkTP can be reused by using same instance name.And there are still too many threads.I am trying to figure out what each thread is for.😂

ifplusor commented 4 years ago

@he1016060110 I am maintaining another branch, if you want to customize thread pool, I will give you a hand.

he1016060110 commented 4 years ago

@he1016060110 I am maintaining another branch, if you want to customize thread pool, I will give sb a hand.

Is it the branch re_dev

ifplusor commented 4 years ago

@he1016060110 You are right.

phaniranjan commented 4 years ago

Recently we tried to evaluate RocketMQ CPP client for our project, while trying to execute examples, tps_thread is null exception is thrown. while debugging tps_thread is not constructed/initialized in the code references. Is this related to any settings/configuration? Can you please provide any pointers to the usage of the client. Any help will be appreciated. image

ifplusor commented 4 years ago

@phaniranjan What example do you run?

phaniranjan commented 4 years ago

@ifplusor I have tried AsyncProducer.cpp & AsyncPushConsumer.cpp, below is the output, not sure if there is any configuration details missing [vectone@localhost example]$ !666 ./AsyncProducer -n "localhost:9876" -g "TestGroup" -t "MyTopicMessage" nameserver: localhost:9876 topic: MyTopicMessage groupname: TestGroup produce content: msgbody for test msg count: 1 thread count: 8 tpsthread is null send Exception send Exception send Exception send Exception send Exception send Exception send Exception per msg time: 10ms ========================finished============================== tpsthread is null [vectone@localhost example]$ !667 ./AsyncPushConsumer -n "localhost:9876" -g "TestGroup" -t "MyTopicMessage" nameserver: localhost:9876 topic: MyTopicMessage groupname: TestGroup produce content: msgbody for test msg count: 1 thread count: 8 tpsthread is null Segmentation fault (core dumped) [vectone@localhost example]$

ifplusor commented 4 years ago

@phaniranjan This is a bug in TpsReportService::start(), please create a new issue, and I will commit a PR to resolve this bug immediately.

ifplusor commented 4 years ago

@phaniranjan See #313