Simulating high latency / intermittent network con

2019-04-08 03:13发布

问题:

I'm load testing a network application using The Grinder (on a Windows PC) and I wish to simulate imperfect network conditions in order to see what effect is has on the application load, in particular I'd like to see the effect of:

  • Variable network latency, so not only do different clients have different latency, but also latency may vary during the test for a single client.
  • Dropped network connections - I wish to simulate what happens when a network connection is abruptly / randomly dropped.

What's the easiest way of doing this?

回答1:

  1. Setup a Linux box as the default router for this machine.
  2. Install 'netem' on the linux box: http://www.linuxfoundation.org/collaborate/workgroups/networking/netem


回答2:

Other options:

  • WanEM (OpenSource, clock timing can be a challenge in the default VM install which produces inconsistent results. Best used wen installed on physical hardware instead of within a virtual machine) WanEm Download location
  • Shunra (Commercial, My preference in a chassis solution) Shunra Products
  • Anue (Commercial, now Ixia) Anue on Ixia Website


回答3:

The fact that the Grinder allows you to dive into its Jython script holds a lot of power to customise the manner in which you'd like to control an "agent's" behaviour.
For example - if you'd like to simulate dropped network connections, say your agent has 100 runs. you can generate an array of random numbers [between 0-99] and for the runs matching any of the random numbers, you can instruct the thread to abort.

However, having said that, the conditions you wish to simulate are more like tweaking the behaviour of the server you're testing. What i provided you is a work-around which may or may not fulfill your expectations. The Grinder as a tool doesn't really offer much to influence the behaviour of the server [to be tested]. it's more like a tool to control the user load and behaviour.

Hope this helps.



回答4:

You may also be interested in the bandwidth throttling feature of the grinder, which caps at arbitrary levels how fast your agent threads can send/receive data across the network. Your HTTP connection has a setBandwidthLimit() method which allows you to do this.