java - Correct way to set the socket send buffer size on linux? -


i have nio server gets small client requests result in ~1meg responses. server uses following accept new client:

socketchannel clientchannel = server.accept(); clientchannel.configureblocking(false); clientchannel.socket().setsendbuffersize(2 * 1024 * 1024); 

i log out "client connected" line includes result of clientchannel.socket().getsendbuffersize().

on windows, set changes client socket's send buffer size 8k 2megs. on linux, socket says send buffer 131,071 bytes.

this results in lousy performance, clientchannel.write writes 128k @ time, takes 7 more passes data written. on windows, setsendbuffersize change improved performance.

linux appears configured allow large socket send buffer:

$ cat /proc/sys/net/ipv4/tcp_wmem 4096    16384   4194304 

the platform free adjust requested buffer size or down, , that's linux appears doing. nothing can except maybe tune maxima via kernel configuration.

note comments in question linked setting buffer sizes > 64k apply receive buffer, not send buffer, because receive buffer size affects window scaling option, needs set before socket connected, sets window scale in stone.m

i don't see why requiring 'more passes' should cause such major performance difference you're asking question. seems me better off adjusting receiver's window size upwards, , doing prior connection above.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -