Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make cassandra io threads configurable #4034

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cfg/rippled-example.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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