Skip to content

Add configurable TCP no-delay for KV connections - #15

Open
adasari wants to merge 1 commit into
couchbase:masterfrom
adasari:adasari/tcp-nodelay-option
Open

adasari wants to merge 1 commit into
couchbase:masterfrom
adasari:adasari/tcp-nodelay-option

Conversation

@adasari

@adasari adasari commented Sep 21, 2026

Copy link
Copy Markdown

Summary

  • Add IoConfig.EnableTCPNoDelay to configure TCP_NODELAY on KV connections.
  • Propagate the option through both standard and DCP agent initialization.
  • Apply the configured value when creating each memcached TCP connection.
  • Preserve the existing default behavior: TCP_NODELAY remains disabled unless explicitly enabled.

Motivation

gocbcore currently calls SetNoDelay(false) for every KV connection without providing a way for applications to override it.

The Java Couchbase client uses Netty, whose DefaultSocketChannelConfig enables TCP_NODELAY by default when supported. A controlled benchmark using bursts of 10 concurrent missing-key GETs showed a significant difference:

Configuration Mean GET latency p50 Throughput
TCP_NODELAY=false 112.89 ms 118.63 ms 84.1 GETs/s
TCP_NODELAY=true 60.00 ms 59.49 ms 166.2 GETs/s

Exposing this setting allows latency-sensitive applications to opt into the same socket behavior without changing the default for existing users.

Testing Done

  • Unit tests added/updated
  • Complete go test ./... suite passes
  • Added a socket-level test that verifies the resulting TCP_NODELAY value for both enabled and disabled configurations

@DemetrisChr

Copy link
Copy Markdown
Contributor

Thanks for the contribution @adasari, this looks like a reasonable change. We need to make sure all SDKs are aligned on this, so it's added to the specification and then we can add this. We'll get back to you when that's done.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants