Reputation: 1698
The send function would cost 3~4 microseconds in my linux server running in 3.10 as the following showes :
struct timeval tv1,tv2;
gettimeofday(&tv1,NULL) ;
send(fd,strsend,strlen(strsend),MSG_NOSIGNAL) ;
gettimeofday(&tv2,NULL) ;
printf("(%d)(%d)\n",tv1.tv_usec,tv2.tv_usec) ;
The strlen(strsend) would be 212 bytes , so I can merge 5 messages of strsend and send , instead of calling send 5 times , it contains 212 * 5 = 1060 which is below MTU 1500 , the send latency is much better than calling send 5 times .
I like to know if I can merge 10 messages and send only once?!
in this case it contains 212 * 10 = 2120 bytes , which is above MTU 1500 , Maybe the latency would be improved since I call send only once , but is there any side effect doing that ?! any config parameter of NIC would be helpful to do division in lowest latency ?! Does the peer side of tcp/ip performance is effected ?!
Upvotes: 0
Views: 613
Reputation: 182883
You should definitely try to aggregate as much information into a single call to send
as you can. 2KB is generally considered an absolute minimum. Otherwise, among other problems, you'll send very small datagrams on the wire and reduce network efficiency.
Upvotes: 1