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"?

Answers


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));

Need Your Help

How can c# service identify current user logon name on Terminal Services Server?

c# service windows-services terminal-services winlogon

How can c# service get the identity (logon name) of a terminal server user that calls it?

Amazon S3 SignatureDoesNotMatch during AJAX upload

scala amazon-s3 base64

Went to rig up an AJAX upload to S3 but the requests are returning with SignatureDoesNotMatch. After double-checking the access key ID and secret, I am at a loss as to the problem. I can confirm th...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.