Both socket and file recommended buffer size
Please, Linux kernel hackers, what is a reasonable buffer size for write(2) syscall to sockets or files, performance-wise? It's clear that it's some pagesize multiple, but which one? Does it matter? What is "too small" and "too big"?
depends on how big your delay to the peer is, let's say you have a 100MBps connection, and a delay of 50ms, then you can calculate
100MBps * 0.050 sec / 8 = 0.625MB = 625KB
but the default window size in Linux 2.6 is around 110KB, which will limit your throught out to around 2.2MBps (110KB / 0.050) so, to fix that you can you setsockopt
int ret, sock, buf_size; sock = socket(AF_INET, SOCK_STREAM, 0); buf_size = 625*1024; ret = setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (char *)&buf_size, sizeof(buf_size)); ret = setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char *)&buf_size, sizeof(buf_size));