Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Giant downgrade of socket performance on Linux  RSS feed

 
Alexey Pilipchuk
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody.

I faced strange problem related to sockets on Linux.
In short words I've got two application communicating to each other through a primitive socket based mechanism:

Server listens to port 5555 on localhost
Client connects to the server.
if it is the first time the server creates new thread for the client.
after that client and server talk through the socket which is not closed until application closes.
Both application are located on the same computer.

The problem. On Windows XP everything works perfectly, but once I moved my applications to Linux (Gentoo, k2.6) the communication nearly stopped. Profiler revealed that up to 90% of the time the apps are waiting for net I/O. After some exploration I found out that if I close all streams and client socket every time the communication is done and reopen it next time the applications on Linux runs as fast as on windows. Apparently I faced some peculiarities of net I/O implementation on Linux. I just don't understand what exactly I did wrong.

Does anybody know what it is all about? I'm interested exactly in this situation no workaround like RMI or whatever.
I'm not Linux guru so if you are going to suggest to check some environment stuff like iptables or whatever please provide more or less exact command which does it.

Thanks in advance.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps you simply aren't flushing your streams? When you write() to a SocketOutputStream (or any other OutputStream) your data isn't guaranteed to be delivered anywhere until you call flush() on the stream. Perhaps your problem is just that you're not calling flush() after writing, so your data is being buffered rather than delivered?
 
Alexey Pilipchuk
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No I do flush. When I didn't I had problems even on Windows
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!