and because of that we decided to set the recv buffer to 512kB via linux kernel parameters.
We didn't had any problems on the official server so we wanted to bake that into code.
There is a calculator https://www.switch.ch/network/tools/tcp_throughput/?mss=1460&rtt=80&loss=1e-06&bw=10&rtt2=500&win=1024&Calculate=Calculate
that said for 10Mbits/ speed 16kB recv buffer and 500ms we only can expect effective 0.24 Mbits of actuall data speed.
Nothing mentioned increasing the send buffer, but it prob cant hurt from a server side or ?

 cat /proc/sys/net/core/wmem_default showed 212992
 cat /proc/sys/net/core/rmem_default showed 212992
 sysctl -w net.ipv4.tcp_wmem="4096 524288 4194304" was beeing used
 sysctl -w net.ipv4.tcp_wmem="4096 16384 4194304" was the default
This commit is contained in:
Marcel Märtens 2023-07-04 23:32:26 +02:00
parent dab040baa4
commit 2101d8264c

View File

@ -122,6 +122,14 @@ impl Protocols {
// See https://docs.rs/tokio/latest/tokio/net/struct.TcpSocket.html
#[cfg(not(windows))]
socket2_socket.set_reuse_address(true)?;
const SEND_BUFFER_SIZE: usize = 262144;
const RECV_BUFFER_SIZE: usize = SEND_BUFFER_SIZE * 2;
if let Err(e) = socket2_socket.set_recv_buffer_size(RECV_BUFFER_SIZE) {
warn!(?e, "Couldn't set recv_buffer size")
};
if let Err(e) = socket2_socket.set_send_buffer_size(SEND_BUFFER_SIZE) {
warn!(?e, "Couldn't set set_buffer size")
};
let socket2_addr = addr.into();
socket2_socket.bind(&socket2_addr)?;
socket2_socket.listen(1024)?;