﻿# TCP_NOTSENT_LOWAT bounds unsent queueing, not peer progress

Use the unsent-byte threshold to reason about producer backpressure while keeping local write readiness separate from delivery and remote consumption.

Author: Retrivium team
Updated: 2026-11-06
Canonical URL: https://retrivium.ai/journal/tcp-notsent-lowat-write-readiness/
Language: en

## The producer runs far ahead of the wire

A process generates response data faster than its TCP path can send it. Successful writes let the producer move on while substantial data waits locally, delaying cancellation and retaining memory. A local unsent-byte threshold can make this queueing boundary explicit. It does not increase link capacity or establish that a remote consumer is making useful progress; it controls when the local writer can continue offering buffered work.

## Identify the queue population

The [Linux IP sysctl reference](https://docs.kernel.org/networking/ip-sysctl.html) describes TCP_NOTSENT_LOWAT as controlling unsent bytes in the socket's write queue. That population differs from bytes already transmitted but awaiting acknowledgement, device queue contents and bytes buffered above the socket by a framework. Record which queue the application observes. A threshold on one transport leg does not bound all buffers in a proxy chain, nor does it automatically account for data still held by a model-output producer.

## Interpret readiness under the documented rule

The reference ties write readiness to unsent bytes below the per-socket value and a write queue that is not full; it also describes limiting additional send buffers when the threshold is hit. A readiness notification is permission to attempt writing under the applicable API contract, not a promise that an arbitrary write completes in full. The application must retain ordinary nonblocking partial-write and retry handling rather than treating a wake-up as consumption of an entire response.

## Separate socket and global ownership

The global tcp_notsent_lowat setting applies to sockets not using the per-socket option, and the documentation says changes affect those sockets immediately. Preserve whether the actual worker sets its own value. A global update may therefore leave explicitly configured sockets unchanged while modifying others. This distinction matters when comparing workers or explaining why an application-level library override defeats a host policy intended to constrain producer queueing.

## Test backpressure and cancellation together

In an isolated fixture, use a controlled producer and a receiver that reads at a known schedule. Observe local queueing, write readiness, accepted byte counts, cancellation and eventual application delivery. [TCP stream semantics](https://man7.org/linux/man-pages/man7/tcp.7.html) do not preserve application record boundaries, so validate the intended message content independently of write-call boundaries. Acceptance should show bounded local producer lead under the chosen policy without corrupting partial-write handling or confusing a slower producer with a faster network.

## Keep failure policy separate

This threshold is not a complete request deadline, remote-read acknowledgement or proof that GPU generation stopped after cancellation. A peer can remain connected while its application does no useful work. The [zero-window timeout guide](/journal/guide-net-tcp-zero-window/) addresses a different failure boundary, and [small-write buffering](/journal/guide-net-tcp-nagle/) explains other reasons produced bytes may not immediately move. Report unsent admission, transmitted progress and accepted application completion separately. No universal threshold or memory-saving measurement follows from the presence of this socket option.
