Thursday, October 10, 2013

Ways to avoid calling services on JVMs that are GCing

Came across a neat 'trick' used in low latency, JVM based service calls used at Linkedin.

You can find it explained here.  Its covered at about the 29 minute mark and the presenter mentions the source from where they picked this up from.  A summary of this is as follows.

The context:  The service client needs to access a cluster of servers and call a service (client based load balancing - a lot of Linkedin software uses this pattern).  GCing servers can obviously add tens or potentially even hundreds of milliseconds to the overall latency.  Service are hosted in this case on Tomcat web containers. 

The solution:  A co located Netty based server is used to 'sense' if the Server JVM is GCing.  The client, round robining request first pings the Netty listener on the target Server.  If the ping is answered in a short time (1 ms for Linkedin) then the client can be reasonably certain that a GC is not in progress on the target server.  This does add a constant overhead of a millisecond (or few) to each call but should mostly be able to avoid GCing servers. 





( Screen capture of the relevant slide)


No comments:

Post a Comment