How to control TCP_NODELAY setting for Scala remote actor?
Question
I'm using Scala's remote actors, but round-trip time (even of a trivial message) is 80ms, presumably due to underlying socket not having the TCP/IP Nagle algorithm disabled (also known as TCP_NODELAY), or at least that's what someone with some experience with Java RMI informs me.
All I'm doing in the client to get a link to the remote actor is
val server=select(Node("127.0.0.1",12111),'server)
Is there some way to get at the underlying socket and invoke java.net.Socket.setTcpNoDelay()
on it ?
Solution
If you need to call setTcpNoDelay() on the underlying Socket without modifying the Scala source code, there are 2 ways to do it.
Implement your own SocketImplFactory: this solution sucks because you will need to implement your own SocketImpl which is not trivial and you can not just wrap the existing SocketImpl because it is not a public API. All I can say here is blame it on whoever designed SocketImplFactory in the first place.
Use AOP
BTW, I think the best way to solve this problem is to modify the Scala remote actor code and submit the patch.