Skip to content

rgw/beast: send small responses without waiting for Nagle's algorithm - #73475

Open
dvanders wants to merge 2 commits into
ceph:mainfrom
dvanders:wip-rgw-small-get
Open

dvanders wants to merge 2 commits into
ceph:mainfrom
dvanders:wip-rgw-small-get

Conversation

@dvanders

@dvanders dvanders commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

With default settings, an S3 GET of a small object from the beast frontend takes ~40 ms, which caps a keep-alive connection at ~25 small GETs per second. https://tracker.ceph.com/issues/82657 has the details.

Cause. RGW writes the response headers (ClientIO::complete_header() flushes them) and then the body (send_body()) as separate writes. Beast sets TCP_NODELAY only with tcp_nodelay=1 in rgw_frontends, and the default is 0. With Nagle's algorithm enabled, a body smaller than a segment waits until the client acknowledges the headers, and Linux clients delay that ACK by up to 40 ms. The option was added in #27008 (2019) to match civetweb's, with Nagle on as the default. Neither cephadm nor Rook sets it. The same mechanism added 40 ms to RGW's own requests to Open Policy Agent in https://tracker.ceph.com/issues/52067.

This PR fixes it twice, so that a deployment that sets tcp_nodelay=0 explicitly is fixed too:

  1. tcp_nodelay defaults to 1 (doc and PendingReleaseNotes updated); tcp_nodelay=0 restores Nagle's algorithm.
  2. The headers go out with the start of the body. complete_header() leaves them in the output buffer, and the first send_body() writes headers and body as one gathered async_write. A response without a body has its headers flushed in complete_request(), which every request reaches. This also saves a send per response.

Results. vstart, 1 memstore OSD, 1 radosgw (rgw_thread_pool_size=512), 16 clients each with one keep-alive connection, anonymous GETs of public-read objects, 20 s per run:

4 KiB GETs/s p50 RGW CPU per 4 KiB GET 64 KiB GETs/s RGW CPU per 64 KiB GET
main, default (tcp_nodelay=0) 381 42.0 ms 1,578 µs* 9,333 855 µs
main, tcp_nodelay=1 10,031 1.55 ms 821 µs 9,116 879 µs
this PR, default 10,450 1.50 ms 746 µs 9,307 813 µs
this PR, tcp_nodelay=0 10,491 1.49 ms 745 µs 9,310 811 µs

* RGW's fixed background CPU divided over only 381 requests per second.

Testing. Besides the runs above, an S3 check passes with this PR in all three tcp_nodelay modes:

  • boto3 PUT/GET/HEAD of 0 B, 1 B, 4 KiB, 64 KiB and 5 MiB multipart objects;
  • a ranged GET, a listing, and a 404 with its error body;
  • 20 raw keep-alive requests and responses on one connection, with each response's framing checked;
  • a GET following a HEAD on the same connection.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)

Assisted by Claude Code (Claude Opus 5.5).

The beast frontend enabled TCP_NODELAY only with tcp_nodelay=1 in
rgw_frontends, and neither cephadm nor Rook sets it. With Nagle's
algorithm on, a response whose body is written after its headers and
is smaller than a segment waits until the client acknowledges the
headers, and Linux clients delay that ACK by up to 40 ms. A 4 KiB GET
took 42 ms at p50 (381/s from 16 keep-alive clients) against 1.7 ms
with tcp_nodelay=1 (9,039/s), on a vstart cluster with one radosgw.

Make tcp_nodelay=1 the default; tcp_nodelay=0 restores Nagle's
algorithm.

Fixes: https://tracker.ceph.com/issues/82657
Assisted-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Dan van der Ster <[email protected]>
ClientIO::complete_header() flushed the headers as soon as they were
complete, and send_body() wrote the body separately, so every response
with a body took at least two sends. With Nagle's algorithm enabled
(tcp_nodelay=0), a small body is then held until the client
acknowledges the headers, up to its delayed-ACK timeout (~40ms on
Linux).

Leave the headers in the output buffer at complete_header(), and have
the first send_body() write them and the body together, as one gathered
write (BuffererSink::write_data_gather(), which StreamIO implements with
one async_write of both buffers). A response without a body gets its
headers flushed in complete_request().

Fixes: https://tracker.ceph.com/issues/82657
Assisted-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Dan van der Ster <[email protected]>
@FredNass

FredNass commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@yuvalif @nbalacha Not sure whether this affected your Lua benchmarks with tiny objects, but I wanted to make sure it was on your radar.

@ivancich
ivancich requested a review from yuvalif November 5, 2026 15:12
@mkogan1

mkogan1 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

tested with hsbench - workload small 4KB obj PUT to a single bucket using 1 thread:

❯ echo ${RANDOM} ; time (nice numactl -N 1 -m 1 -- env GOMAXPROCS=$(( $(numactl -N 0 -- nproc) / 4 )) ~/go/bin/hsbench -a b2345678901234567890 -s b234567890123456789012345678901234567890 -u http://127.0.0.1:8000
-z 4K -zd -d -1 -t 1 -b 1 -n 10000 -m cxip -bp "b01b-${RANDOM}-" -op 'folder01/stage01_')

screenshot on main 08f4d0f633c, beast params:

  • top without this PR & --rgw_frontends="beast port=8000 tcp_nodelay=1"
  • middle without this PR & --rgw_frontends="beast port=8000 tcp_nodelay=0"
  • bottom with commits from this PR & --rgw_frontends="beast port=8000 tcp_nodelay=1"
Image

next tested with hsbench - workload small 4KB obj PUT to a multiple buckets using multiple threads:

❯ echo ${RANDOM} ; time (nice numactl -N 1 -m 1 -- env GOMAXPROCS=$(( $(numactl -N 0 -- nproc) / 4 )) ~/go/bin/hsbench -a b2345678901234567890 -s b234567890123456789012345678901234567890 -u http://127.0.0.1:8000
-z 4K -zd -d -1 -t $(( $(numactl -N 0 -- nproc) * 2 )) -b $(( $(numactl -N 0 -- nproc) * 4 )) -n 100000 -m cxip -bp "b01b-${RANDOM}-" -op 'folder01/stage01_')

again, screenshot on main 08f4d0f633c, beast params:

  • top without this PR & --rgw_frontends="beast port=8000 tcp_nodelay=1"
  • middle without this PR & --rgw_frontends="beast port=8000 tcp_nodelay=0"
  • bottom with commits from this PR & --rgw_frontends="beast port=8000 tcp_nodelay=1"
Image

@mkogan1

mkogan1 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

added needs-qa tag

@anrao19

anrao19 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to wip-anrao9-testing-2026-11-13-0841-main.

@anthonyeleven anthonyeleven left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, esp. given how last I checked it was impossible to disable Nagle with Rook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants