mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
make cassandra io threads configurable
This commit is contained in:
@@ -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.
|
||||
#
|
||||
# Notes:
|
||||
# The 'node_db' entry configures the primary, persistent storage.
|
||||
|
||||
@@ -249,18 +249,22 @@ public:
|
||||
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
|
||||
@@ -275,6 +279,7 @@ public:
|
||||
return;
|
||||
;
|
||||
}
|
||||
cass_cluster_set_request_timeout(cluster, 2000);
|
||||
|
||||
std::string certfile = get(config_, "certfile");
|
||||
if (certfile.size())
|
||||
@@ -466,12 +471,6 @@ public:
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user