Performance affected from the socket buffer size
843790Jul 31 2009 — edited Aug 3 2009I have a server program deployed in the Tomcat server.
I found the server was sometime blocked in the native method java.net.SocketOutputStream.socketWrite0(Native Method). And the CPU was not fully utilized.
Intuitive thinking, may be I can solve this problem by increasing the socket send buffer size. So I tried it.
By default, tomcat socket send buffer size is 9000 bytes or so. I increased this value to 102400 bytes. Tested again. CPU usage was around 100%. OK, it worked.
But how about if I decrease this value to a small number? I tried. Set the value to 100 bytes. Tested again. CPU usage was still around 100% !!!
So, the problem here is: CPU was not able to be fully utilized by using the default buffer size (9000 bytes). But if you increase the value to a very large number or a very small number, you can achieve a better performance.
note: the client was sending requests all the time. Just like the stress test. So, the server side was always busy.
Edited by: willpowerforever on Jul 31, 2009 6:37 PM