diff --git a/cfg/rippled-example.cfg b/cfg/rippled-example.cfg index b9d16c3bf16..da5100d7c28 100644 --- a/cfg/rippled-example.cfg +++ b/cfg/rippled-example.cfg @@ -1132,6 +1132,9 @@ # cluster. Setting this option can help eliminate # write timeouts and other write errors due to the # cluster being overloaded. +# io_threads +# Set the number of IO threads used by the +# Cassandra driver. Defaults to 4. # # Notes: # The 'node_db' entry configures the primary, persistent storage. diff --git a/src/ripple/nodestore/backend/CassandraFactory.cpp b/src/ripple/nodestore/backend/CassandraFactory.cpp index 10282d94b70..c8d0c139c44 100644 --- a/src/ripple/nodestore/backend/CassandraFactory.cpp +++ b/src/ripple/nodestore/backend/CassandraFactory.cpp @@ -249,18 +249,22 @@ class CassandraBackend : public Backend cluster, username.c_str(), get(config_, "password").c_str()); } - unsigned int const workers = std::thread::hardware_concurrency(); - rc = cass_cluster_set_num_threads_io(cluster, workers); + unsigned int const ioThreads = get(config_, "io_threads", 4); + maxRequestsOutstanding = + get(config_, "max_requests_outstanding", 10000000); + JLOG(j_.info()) << "Configuring Cassandra driver to use " << ioThreads + << " IO threads. Capping maximum pending requests at " + << maxRequestsOutstanding; + rc = cass_cluster_set_num_threads_io(cluster, ioThreads); if (rc != CASS_OK) { std::stringstream ss; - ss << "nodestore: Error setting Cassandra io threads to " << workers - << ", result: " << rc << ", " << cass_error_desc(rc); + ss << "nodestore: Error setting Cassandra io threads to " + << ioThreads << ", result: " << rc << ", " + << cass_error_desc(rc); Throw(ss.str()); } - cass_cluster_set_request_timeout(cluster, 2000); - rc = cass_cluster_set_queue_size_io( cluster, maxRequestsOutstanding); // This number needs to scale w/ the @@ -275,6 +279,7 @@ class CassandraBackend : public Backend return; ; } + cass_cluster_set_request_timeout(cluster, 2000); std::string certfile = get(config_, "certfile"); if (certfile.size()) @@ -466,12 +471,6 @@ class CassandraBackend : public Backend work_.emplace(ioContext_); ioThread_ = std::thread{[this]() { ioContext_.run(); }}; open_ = true; - - if (config_.exists("max_requests_outstanding")) - { - maxRequestsOutstanding = - get(config_, "max_requests_outstanding"); - } } // Close the connection to the database