Skip to content

Commit

Permalink
make cassandra io threads configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
CJ Cobb authored and manojsdoshi committed Dec 15, 2021
1 parent c663f1f commit 72752b1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
3 changes: 3 additions & 0 deletions cfg/rippled-example.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,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.

This comment has been minimized.

Copy link
@eness89

eness89 Dec 25, 2021

if(

#
# Notes:
# The 'node_db' entry configures the primary, persistent storage.
Expand Down
23 changes: 11 additions & 12 deletions src/ripple/nodestore/backend/CassandraFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(config_, "io_threads", 4);
maxRequestsOutstanding =
get<int>(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<std::runtime_error>(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
Expand All @@ -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())
Expand Down Expand Up @@ -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<int>(config_, "max_requests_outstanding");
}
}

// Close the connection to the database
Expand Down

0 comments on commit 72752b1

Please sign in to comment.