This uses Jmeter 2.4 (available here)
Given the time it takes to ramp up and down all of the virtual users in a stress test, I’ve often wanted to tweak the throughput and load in Jmeter, live, during a test so that I can immediately see the feedback in the environment via Perfmon or whatever monitoring tool I am using. Jmeter gives you the means to do just that via Telnet! However, I’ve taken this one step further and written a crude UI Application to wrap the Telnet calls. But more on that later in the post!
The first thing you need to do is to set up Jmeter to ‘open up’ the running Jmeter application instance so that you can connect externally via Telnet. Modify your bin/jmeter.properties file so that the beanshell.server.port property is set (its probably there but commented out):
Now when you start Jmeter, two ports will be opened on your system – 9000 which is a HTTP Server, and 9001 which is a Telnet Server. Ensure your firewall has not blocked these ports. You can read all of the information about this here in 16.7 and will not repeat it.
Suffice to say, if you open up your browser and navigate to:
…you will get access to the JSwing Console. Or, you can use the standard Telnet in CMD.EXE and do this:
telnet localhost 9001
You are now ‘in’ the running Jmeter instance and you can change its properties using this as a starting point. However, that’s all a bit clunky and the Telnet session is not friendly to mistakes – what I wanted was a simple User Interface tool in C# that would let me change Jmeter Properties during a test (such as Throughput) without using Telnet:
The ‘Get All Properties From Jmeter’ and ‘Send Property Value to Jmeter’ buttons make the Telnet calls to Jmeter on our behalf behind the scenes.
You can download all of the source code here. It includes the C# Application (already built), the source code (Visual Studio 2010/.Net 2.0) and the simple JMX file. If you open up the JMX file, you will see the following property set up which dictates the Throughput:
… and the ‘Constant Throughput Timer’ set to that value:
As it stands, that means ‘make 12 requests every minute’. But if we changed the value of ‘REQUESTSPERMINUTE’ whilst the test is running, we could vary the load on demand. To show this working:
1. Ensure that beanshell.server.port=9000 is set in the jmeter.properties files.
2. Start up Jmeter and make sure none of your previous Telnet sessions are running.
3. Open up the JMX file (it is in the Zip file mentioned earlier) and run it. Observe the TreeView – it should make a request to Google about every 5 seconds.
4. Start the C# Application.
5. Set the IP Address of the Server and the Port Number. Assuming you are running it on the same machine as Jmeter and using the default port, you have nothing to change.
6. Click ‘Get All Properties from Jmeter’. Behind the scenes, this will Telnet into Jmeter and pull out all of its properties. Of interest is the REQUESTSPERMINUTE Property that was set by the load test:
7. Select that property and change the value to ’30′. Click ‘Send Property Value to Jmeter’.
8. Assuming your connection to the Internet is fast, you should start seeing one request to Google every 2 seconds (ie: 30 per minute).
I’ve given you ‘just enough’ to get going with this… there is very little error checking in the UI and the code uses synchronous blocking calls and rather obscure sentinels to establish when all Telnet content has been returned.