micronaut-gcp icon indicating copy to clipboard operation
micronaut-gcp copied to clipboard

Allow custom systemExecutorProvider to be specified via configuration for subscribers

Open krjura opened this issue 2 years ago • 0 comments

Feature description

Today I was debugging very high thread usage of one of my applications.

In the thread dump I noticed a lot of threads called "Subscriber-SE-<x>-<y>". These threads are created by "com.google.cloud.pubsub.v1.Subscriber" in the build() method.

It seems that if the systemExecutorProvider is not set in the subscriber, a new ScheduledExecutorService will be created with a minimum of 6 threads (or more based on parallelPullCount). This is done for every subscriber.

In my case these threads where mostly waiting and not doing anything.

Looking at https://github.com/micronaut-projects/micronaut-gcp/blob/master/gcp-pubsub/src/main/java/io/micronaut/gcp/pubsub/bind/DefaultSubscriberFactory.java#L78 micronaut is setting ExecutorProvider but not the SystemExecutorProvider.

It is possible to add a new configuration property in gcp.pubsub.subscriber.* namespace (for example gcp.pubsub.subscriber.*.system-executor) that will allow configuration of a shared system executor?

krjura avatar Sep 08 '22 14:09 krjura