When designing tests that mirror real-world behaviors, we may find the need to route more requests to one target test endpoint over another. The JMeter Weighted Switch Controller provides a method of asymmetrically routing requests to two or more target test endpoints. You can assign higher weights to samplers being run and proportionally more frequently than samplers with lower assigned weights. In this brief article, we will show you how to set up the Weighted Switch Controller.
Installing the JMeter Weighted Switch Controller
You can use the JMeter Plugin Manager to search for publicly available components hosted on jmeter-plugins.org. From the Options menu select “JMeter Plugin Manager”:
Click on the “Available” tab and type “weighted” to locate the plugin. From there you can select the plugin on the left and click “Apply Changes and Restart JMeter”, as installing will require a restart of the GUI.
Configuring the JMeter Weighted Switch Controller
For a test with multiple samplers, you can add these under the Weighted Switch Controller, which is typically added inside a thread group. In the example below, we have two HTTP Request samplers. The configuration is such that “Request A” will receive 75% of requests, while the remaining 25% of requests will be routed via “Request B”:
It should be noted that weights are expressed in terms of proportions, and do not necessarily need to add up to 100. We would get the same result if we configured “Request A” with a weight of 3 and “Request B” with a weight of 1, thereby attaining 3:4 and 1:4 proportions which are equivalent. Expressing in terms of 100 however may be convenient as we have done above.
Did you know that RedLine13 offers a full-featured, time-limited free trial? Sign up now, and start testing today!