Skip to content

Commit ee51bf8

Browse files
authored
Merge pull request ceph#62011 from kchheda3/wip-allow-multiple-rgws
rgw/frontend: Allow multiple RGWs to run on same port on same host Reviewed-by: Adam C. Emerson <[email protected]>
2 parents 836ebab + b247306 commit ee51bf8

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

PendingReleaseNotes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
* RGW: Adding missing quotes to the ETag values returned by S3 CopyPart,
2222
PostObject and CompleteMultipartUpload responses.
2323
* RGW: Added support for S3 GetObjectAttributes.
24+
* RGW: Added BEAST frontend option 'so_reuseport' which facilitates running multiple
25+
RGW instances on the same host by sharing a single TCP port.
2426

2527
* RBD: All Python APIs that produce timestamps now return "aware" `datetime`
2628
objects instead of "naive" ones (i.e. those including time zone information

doc/radosgw/frontends.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,17 @@ Options
135135
:Default: ``16384``
136136
:Maximum: ``65536``
137137

138+
``so_reuseport``
139+
140+
:Description: If set allows multiple RGW instances on a host to listen on the same TCP port.
141+
142+
``1`` Enable running multiple RGW on same port.
143+
144+
``0`` Disallow running multiple RGW on same port.
145+
146+
:Type: Integer (0 or 1)
147+
:Default: 0
148+
138149

139150
Generic Options
140151
===============

src/rgw/rgw_asio_frontend.cc

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,12 @@ int AsioFrontend::init()
707707
l.use_nodelay = (nodelay->second == "1");
708708
}
709709
}
710-
711710

711+
bool reuse_port = false;
712+
auto reuse_port_it = config.find("so_reuseport");
713+
if (reuse_port_it != config.end()) {
714+
reuse_port = (reuse_port_it->second == "1");
715+
}
712716
bool socket_bound = false;
713717
// start listeners
714718
for (auto& l : listeners) {
@@ -733,7 +737,21 @@ int AsioFrontend::init()
733737
}
734738
}
735739

736-
l.acceptor.set_option(tcp::acceptor::reuse_address(true));
740+
if (reuse_port) {
741+
// setting option |SO_REUSEPORT| allows running of multiple rgw processes on
742+
// the same port. Can read more about the implementation here.
743+
// https://web.git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=c617f398edd4db2b8567a28e899a88f8f574798d
744+
int one = 1;
745+
if (setsockopt(l.acceptor.native_handle(), SOL_SOCKET,
746+
SO_REUSEADDR | SO_REUSEPORT, &one, sizeof(one)) == -1) {
747+
lderr(ctx()) << "setsockopt SO_REUSEADDR | SO_REUSEPORT failed:" <<
748+
dendl;
749+
return -1;
750+
}
751+
} else {
752+
l.acceptor.set_option(tcp::acceptor::reuse_address(true));
753+
}
754+
737755
l.acceptor.bind(l.endpoint, ec);
738756
if (ec) {
739757
lderr(ctx()) << "failed to bind address " << l.endpoint

0 commit comments

Comments
 (0)