]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: make max_connections configurable in beast 33341/head
authorTiago Pasqualini <tiago.pasqualini@canonical.com>
Fri, 31 Jan 2020 18:22:19 +0000 (15:22 -0300)
committerTiago Pasqualini <tiago.pasqualini@canonical.com>
Mon, 17 Feb 2020 21:12:07 +0000 (18:12 -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>
(cherry picked from commit d6dada5bcb356abaef8d9237ceca8f42d4fcfb74)

Conflicts:
        src/rgw/rgw_asio_frontend.cc
- trivial resolution

doc/radosgw/frontends.rst
src/rgw/rgw_asio_frontend.cc

index ce58c6ee2c9b594ec87b10416f09de7672bb8fd5..d6f5d8d278df470a74678c196232cf6d2127b20a 100644 (file)
@@ -70,6 +70,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 dbefeb0c3ab7f3dd9c6e7dcfaa95c8e4100bd584..2557b5f47c4a5a7c40fd6fe683abf88abe0b5f8b 100644 (file)
@@ -11,6 +11,7 @@
 #include <boost/asio/spawn.hpp>
 
 #include "common/errno.h"
+#include "common/strtol.h"
 
 #include "rgw_asio_client.h"
 #include "rgw_asio_frontend.h"
@@ -395,7 +396,18 @@ int AsioFrontend::init()
           << ": " << ec.message() << dendl;
       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);