Skip to content
Snippets Groups Projects
Commit 84bb149d authored by Tigran Mkrtchyan's avatar Tigran Mkrtchyan :coffee: Committed by Michael Davis
Browse files

frontend-grpc: limit the number of request processing threads

parent a987b047
Branches 314-remove-grpc-client-code-from-cta-frontend-2
No related tags found
No related merge requests found
Pipeline #52628 failed
......@@ -7,6 +7,7 @@
- cta/CTA#245 - Implements cta-admin functions in cta-frontend-grpc
- cta/CTA#213 - Skip files with paths that have valid metadata
- cta/CTA#321 - Add arguments to cta-change-storage-class to validate that the correct files are being changed
- cta/CTA#318 - Limit the number of frontend-grpc request processing threads
### Bug Fixes
- cta/CTA#305 - AllCatalogueSchema file not created when updating schema
- cta/CTA#309 - Ignore 'NoSuchObject' exceptions thrown by non-existing objects during retrieve job requeuing
......
......@@ -3,6 +3,7 @@
#include "version.h"
#include <grpcpp/grpcpp.h>
#include <grpcpp/resource_quota.h>
#include <grpcpp/security/server_credentials.h>
#include <scheduler/Scheduler.hpp>
......@@ -13,6 +14,7 @@ using cta::Scheduler;
using cta::catalogue::Catalogue;
using cta::frontend::rpc::CtaRpc;
using grpc::ResourceQuota;
using grpc::Server;
using grpc::ServerBuilder;
using grpc::ServerContext;
......
......@@ -44,7 +44,8 @@ std::string help =
"\n"
"where options can be:\n"
"\n"
"\t--port <port>, -p <port>:\tTCP port number to use, defaults to 17017\n"
"\t--threads <N>, -c <N> \tnumber of threads to process concurrent requests, defaults to 8x#CPUs\n"
"\t--port <port>, -p <port> \tTCP port number to use, defaults to 17017\n"
"\t--log-header, -n \tadd hostname and timestamp to log outputs, default\n"
"\t--no-log-header, -s \tdon't add hostname and timestamp to log outputs\n"
"\t--tls, -t \tenable Transport Layer Security (TLS)\n"
......@@ -53,6 +54,7 @@ std::string help =
static struct option long_options[] =
{
{"threads", required_argument, 0, 'c'},
{"port", required_argument, 0, 'p'},
{"log-header", no_argument, 0, 'n'},
{"no-log-header", no_argument, 0, 's'},
......@@ -88,8 +90,9 @@ int main(const int argc, char *const *const argv) {
int option_index = 0;
const std::string shortHostName = utils::getShortHostname();
bool useTLS = false;
int threads = 8 * std::thread::hardware_concurrency();
while( (c = getopt_long(argc, argv, "p:nshv", long_options, &option_index)) != EOF) {
while( (c = getopt_long(argc, argv, "c:p:nshv", long_options, &option_index)) != EOF) {
switch(c) {
case 'p':
......@@ -110,6 +113,9 @@ int main(const int argc, char *const *const argv) {
case 't':
useTLS = true;
break;
case 'c':
threads = std::atoi(optarg);
break;
default:
printHelpAndExit(1);
}
......@@ -192,6 +198,12 @@ int main(const int argc, char *const *const argv) {
// Listen on the given address without any authentication mechanism.
builder.AddListeningPort(server_address, creds);
// fixed the number of request threads
ResourceQuota quota;
quota.SetMaxThreads(threads);
lc.log(log::INFO, "Using " + std::to_string(threads) + " request processing threads");
builder.SetResourceQuota(quota);
// Register "service" as the instance through which we'll communicate with
// clients. In this case it corresponds to an *synchronous* service.
builder.RegisterService(&svc);
......
......@@ -13,12 +13,12 @@
.\" You should have received a copy of the GNU General Public License
.\" along with this program. If not, see <http://www.gnu.org/licenses/>.
.TH CTA-FRONTEND-GRPC "1cta" "2022-07-12" "CTA" "The CERN Tape Archive (CTA)"
.TH CTA-FRONTEND-GRPC "1cta" "2023-03-07" "CTA" "The CERN Tape Archive (CTA)"
.SH NAME
cta-frontend-grpc \- gRPC-based Frontend for CTA
.SH SYNOPSIS
\fBcta-frontend-grpc\fP [--port \fIport\fR] [--log-header|--no-log-header] [--tls] [--version] [--help]
\fBcta-frontend-grpc\fP [--port \fIport\fR] [--log-header|--no-log-header] [--tls] [--threads \fIN\fR] [--version] [--help]
.SH DESCRIPTION
\fBcta-frontend-grpc\fP is the daemon process providing gRPC endpoint for integration with storage systems.
......@@ -28,6 +28,9 @@ cta-frontend-grpc \- gRPC-based Frontend for CTA
\-p, \-\-port \fIport\fR
TCP port used to accept connections from dCache.
.TP
\-c, \-\-threads \fIN\fR
Maximal number of threads to process gRPC requests. The dafaults to 8x #CPUs.
.TP
\-n, \-\-log\-header
Include timestamp and host name into the log messages.
.TP
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment