Skip to content

Commit

Permalink
Disable stats recorder for built-in PulsarClient (#12217)
Browse files Browse the repository at this point in the history
### Motivation

In `PulsarService`, there's a built-in client used in many places, like topic compaction, system topics read/write. It could also be used in protocol handlers. Different with the manually created Pulsar client, it can read the configured authentication params and TLS related configs for broker-to-broker communication.

However, it doesn't change the default `statsIntervalSeconds` config, which means each time a producer/consumer/reader is created, a stats recorder (`ProducerStatsRecorderImpl` or `ConsumerStatsRecorderImpl`) will be created, in which there's a Netty `TimerTask` that prints stats periodically (the default interval is 1 minute). If there're many producers/consumers/readers created by this built-in client, the unnecessary CPU usage will be high.

### Modifications

Configure the `statsIntervalSeconds` with zero value to disable stats recorder.
  • Loading branch information
BewareMyPower authored Sep 28, 2021
1 parent 9abd6d3 commit 52232e6
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,8 @@ public synchronized PulsarClient getClient() throws PulsarServerException {
this.getConfiguration().getBrokerClientAuthenticationPlugin(),
this.getConfiguration().getBrokerClientAuthenticationParameters()));
}

conf.setStatsIntervalSeconds(0);
this.client = new PulsarClientImpl(conf, ioEventLoopGroup);
} catch (Exception e) {
throw new PulsarServerException(e);
Expand Down

0 comments on commit 52232e6

Please sign in to comment.