Too Many Instances Detected Event The number of connected Cluster instances (2) exceeds the configured limit (1)

Getting this warn:

WARN [2023-02-14 14:46:51,301] com.couchbase.core: [com.couchbase.core][TooManyInstancesDetectedEvent] The number of connected Cluster instances (2) exceeds the configured limit (1). It is recommended to create only one instance and reuse it across the application lifetime. Also, make sure to disconnect Clusters if they are not used anymore.

We need to connect to multiple clusters in this application. What is the recommended best practice for doing this?

Update:
I found this:

Which looks like we can control from here:

Is there any reason why we shouldn’t be setting that? Is that all that’s required?

Hi @unhuman!

Is there any reason why we shouldn’t be setting that? Is that all that’s required?

it’s safe to call Cluster.maxAllowedInstances to match your expected number of clusters. This suppresses the warning.

Before increasing the limit, you might want to evaluate whether you would prefer to share a single ClusterEnvironment between multiple clusters. Sharing the environment is not always possible, since most config options are bound to a specific environment. However, if your clusters all use the same config options, sharing the environment can be beneficial because it results in the creation of fewer heavy resources like threads and schedulers.

Thanks,
David

1 Like

Perfect, thanks. We are already sharing ClusterEnvironment (same config), without issues.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.