diff --git a/docs/source/corda-configuration-file.rst b/docs/source/corda-configuration-file.rst index b1c3e20e48..50ec7651fc 100644 --- a/docs/source/corda-configuration-file.rst +++ b/docs/source/corda-configuration-file.rst @@ -300,7 +300,7 @@ absolute path to the node's base directory. Corda Enterprise allows the node operators to configure the number of threads the state machine manager can use to execute flows in parallel, allowing more than one flow to be active and/or use resources at the same time. - The default value is 4 times the number of cores available which was found to be working efficiently in + The default value is 2 times the number of cores available which was found to be working efficiently in performance testing. The ideal value for this parameter depends on a number of factors. The main ones are the hardware the node is running on, the performance profile of the @@ -308,7 +308,7 @@ absolute path to the node's base directory. so for n threads, the database system must have at least n+1 connections available. Also, the database must be able to actually cope with the level of parallelism to make the number of threads worthwhile - if using e.g. H2, any number beyond 8 does not add any substantial benefit due to limitations with its internal - architecture. + architecture. For these reasons, the default size for the flow framework thread pool is the minimum between two times the available number of processors and 30. Overriding this value in the configuration allows to specify any number. :rpcThreadPoolSize: The number of threads handling RPC calls - this defines how many RPC requests can be handled in parallel without queueing. The default value is set to the number of available processor cores. diff --git a/node/src/main/kotlin/net/corda/node/services/config/ConfigUtilities.kt b/node/src/main/kotlin/net/corda/node/services/config/ConfigUtilities.kt index 254d02a978..6359a764dc 100644 --- a/node/src/main/kotlin/net/corda/node/services/config/ConfigUtilities.kt +++ b/node/src/main/kotlin/net/corda/node/services/config/ConfigUtilities.kt @@ -27,12 +27,16 @@ import net.corda.nodeapi.internal.crypto.loadKeyStore import net.corda.nodeapi.internal.crypto.save import org.slf4j.LoggerFactory import java.nio.file.Path +import kotlin.math.min fun configOf(vararg pairs: Pair): Config = ConfigFactory.parseMap(mapOf(*pairs)) operator fun Config.plus(overrides: Map): Config = ConfigFactory.parseMap(overrides).withFallback(this) object ConfigHelper { + // 30 is a temporary max to prevent issues with max server-side allowed database connections, until we switch to proper pooling. + private const val FLOW_THREAD_POOL_SIZE_MAX = 30 + const val CORDA_PROPERTY_PREFIX = "corda." private val log = LoggerFactory.getLogger(javaClass) @@ -51,7 +55,8 @@ object ConfigHelper { // Detect the number of cores val coreCount = Runtime.getRuntime().availableProcessors() - val multiThreadingConfig = configOf("enterpriseConfiguration.tuning.flowThreadPoolSize" to (coreCount * 4).toString(), + val flowThreadPoolSize = min(2 * coreCount, FLOW_THREAD_POOL_SIZE_MAX) + val multiThreadingConfig = configOf("enterpriseConfiguration.tuning.flowThreadPoolSize" to flowThreadPoolSize.toString(), "enterpriseConfiguration.tuning.rpcThreadPoolSize" to (coreCount).toString()) val systemOverrides = systemProperties().cordaEntriesOnly()