]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: make max_connections configurable in beast 33053/head
authorTiago Pasqualini <tiago.pasqualini@canonical.com>
Fri, 31 Jan 2020 18:22:19 +0000 (15:22 -0300)
committerTiago Pasqualini <tiago.pasqualini@canonical.com>
Thu, 6 Feb 2020 20:42:38 +0000 (17:42 -0300)
Beast frontend currently accepts a hardcoded number of connections
that is defined by boost::asio::socket_base::max_connections. This
commit makes it configurable via a 'max_connections' config option
on rgw frontend.

Fixes: https://tracker.ceph.com/issues/43952
Signed-off-by: Tiago Pasqualini <tiago.pasqualini@canonical.com>
doc/radosgw/frontends.rst
src/rgw/rgw_asio_frontend.cc

index 1ab4ad73bc46d7fd33806e856f0842ca5839e7ea..e863a7d2728fb77ccbf7f2078cf78a6745a76742 100644 (file)
@@ -73,6 +73,15 @@ Options
 :Type: Integer (0 or 1)
 :Default: 0
 
+``max_connection_backlog``
+
+:Description: Optional value to define the maximum size for the queue of
+              connections waiting to be accepted. If not configured, the value
+              from ``boost::asio::socket_base::max_connections`` will be used.
+
+:Type: Integer
+:Default: None
+
 
 Civetweb
 ========
index fdd96bf32823bb7ee24c1dde07dc6bf4361f036c..8958d9d67b30adc04fdadc4b670cc49b5a2e67a0 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "common/async/shared_mutex.h"
 #include "common/errno.h"
+#include "common/strtol.h"
 
 #include "rgw_asio_client.h"
 #include "rgw_asio_frontend.h"
@@ -473,7 +474,17 @@ int AsioFrontend::init()
       return -ec.value();
     }
 
-    l.acceptor.listen(boost::asio::socket_base::max_connections);
+    auto it = config.find("max_connection_backlog");
+    auto max_connection_backlog = boost::asio::socket_base::max_listen_connections;
+    if (it != config.end()) {
+      string err;
+      max_connection_backlog = strict_strtol(it->second.c_str(), 10, &err);
+      if (!err.empty()) {
+        ldout(ctx(), 0) << "WARNING: invalid value for max_connection_backlog=" << it->second << dendl;
+        max_connection_backlog = boost::asio::socket_base::max_listen_connections;
+      }
+    }
+    l.acceptor.listen(max_connection_backlog);
     l.acceptor.async_accept(l.socket,
                             [this, &l] (boost::system::error_code ec) {
                               accept(l, ec);