net.ipv4.tcp_rmem Minimum Buffer Size

Latest response

Hello there,

I came around following knowledge base which recommends setting

net.ipv4.tcp_rmem and net.ipv4.tcp_wmem minimum buffer size as

8192 bytes to hold 2 memory pages of data.

However, I did not understand the reason behind how keeping 2

memory pages of data will improve the overall performance.

I will appreciate if anybody can clear it up for me.

https://access.redhat.com/solutions/168483

thanks and Regards,

Responses

This is the minimum size a buffer can shrink to under heavy memory pressure.

I suggest if you're encountering such heavy memory reclaim that using 1 page or 2 pages makes a difference, the system is far under-spec for its workload and needs a lot more RAM.

Hello Jamie,

Does it have a direct relation with MTU used in network ? we have 9216 MTU size so even covering 2 pages will

not fit in this case ?

Thanks

That's a good point.

You probably want the minimum buffer size to be at least double the largest single write you want to do, or largest single message you expect to receive, even under memory pressure.

So ~9000 bytes rounds up to the nearest 4 KiB page at 12288 (12 KiB), double that is 24576 (24 KiB).

So a sensible setting for rmem and wmem could be something like: 24576 262144 16777216