开发者

Is there a way to introduce fake latency in Java RMI calls?

In want to diagnose开发者_如何学C a bottleneck which happens when my client is talking to a server on the other side of the world. I'd like to run the server on my local machine and simulate the latency. Is there a way I can inject a brief thread-sleep in all remote calls? I'm not sure which remote call is the bottleneck, so I need to delay them all.

Second attempt to clarify: I don't want to copy-paste thread sleeps into every single remote method, because there are lots and lots of remote methods. I'm trying to find a way to inject a sleep into the RMI subsystem so all calls over RMI will be delayed.


WANem is designed to do just that. It works at the network level so isn't Java- or RMI-specific.


The Charles Proxy server has a feature where it can add throttling/latency to a connection:

http://www.charlesproxy.com/documentation/proxying/throttling/

I have been very pleased with Charles -- well worth the $50 for a license.


Can you write a proxy server? The client talks to the proxy, the proxy makes the same method call to the server. This way you reconfigure the client but don't need to change the code. The proxy can add delays and log the calls and response.


There is an application for Windows called SoftPerfect Connection Emulator. Simulates latency and if necessary losses or bandwidth limit. See http://www.softperfect.com/products/connectionemulator/


Latency could be introduced by implementing and injecting your own RMISocketFactory via calling setSocketFactory.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜