Sun, 21 Mar 04
The Grinder
I did some performance testing against a web application that I helped write this weekend. I used The Grinder and was quite happy with the beta version. This lets you write scripts in Jython and uses the quite nice HTTPClient library. The Grinder, like most other performance tools, has an admin interface (the console) and a set up distributed agents that are given tasks and communicate results back via the network to the console. I used the HTTP client, but it looks like you can ‘grind’ anything you can talk to via java, from databases to email servers.
I did run into a few problems. I’m using cygwin on WinXP, and had some difficulties running java from the command line. The fix was to use the cygpath command, like so:
#!/bin/sh
# to start the agent
JAVA=/cygdrive/c/j2sdk1.4.2_03/bin/java
CLASSPATH=`cygpath -p -w /home/Owner/work/grinder/grinder-3.0-beta20/lib/grinder.jar:\
/home/Owner/work/grinder/grinder-3.0-beta20/lib/jakarta-oro-2.0.6.jar:\
/home/Owner/work/grinder/grinder-3.0-beta20/lib/jython.jar`
$JAVA -cp $CLASSPATH net.grinder.Grinder
The client application that I was testing doesn’t use cookies (it’s a J2ME application, and the MIDP spec doesn’t support cookies out of the box). Or rather, it uses cookies, but only to grab the first one that the server sends, store it off, and then pass it back as a query parameter. This type of configuration isn’t The Grinder’s sweet spot, and I had to do a bit of hacking to make sure the appropriate cookie value was sent with the appropriate client request. It would have been nice to use contexts but The Grinder wraps the HTTPConnection in its own class. Apparently, if you are simulating use by a browser, cookies are apparently handled correctly. One gripe–there’s no javadoc for the main classes available on The Grinder’s website, so you have to grab the source if you want to see interactions between pieces (for example, how net.grinder.plugin.http.HTTPRequest interacts with HTTPClient.HTTPConnection).
I also mucked with some of the properties, primarily initialSleepTime. You’ll want to make sure that you read about these properties–I blithely uncommented what was in the sample grinder.properties and ended up with an obscene value for grinder.sleepTimeFactor.
After all the setup, I was able to hammer our server. I discovered two useful things: an error in our logout code, which threw exceptions around 10% of the time, and also discovered that our connection timeout between Apache and Tomcat was set incorrectly. Changing this from 0 to 1000 fixed the dreaded SEVERE: All threads are busy, waiting. Please increase maxThreads or check the servlet status error that I was getting. In addition to these two useful bugs, by making some assumptions about how the application will be used, I was able to gimmick up some interesting numbers about supportable users.
I like The Grinder a fair bit. It’s got a nice GUI. It’s still under active development. I’m a bit leery of using beta software (especially open source beta software), but a poll on the homepage convinced me to try the beta. By using this, I was also able to pick up snatches of python which is a new language to me (finally got to consult my long unused copy of Learning Python). I considered looking at JMeter, but The Grinder appears to be a bit more recently maintained. It’s no LoadRunner, but then again, it doesn’t pretend to be. All in all, if you’re in the market for a cheap, quick performance tool, The Grinder is worth a look.
« Miswanting and web application frameworks | Permalink | Spamorama »
Kris Thompson said,
March 22, 2004 at 8:30 am
Besides JMeter’s lack of maintaince is there any other strong reason for using Grinder? Do you feel that if users know JMeter they should switch?
Dan Moore said,
March 22, 2004 at 9:41 am
From looking at JMeter, it appears to have a much nicer user interface both for building tests and displaying results. You can build a test visually, which is something that The Grinder just doesn’t let you do (at least V3–I don’t know about The Grinder V2).
The big plus of The Grinder is being able to use jython to write arbitrary tests. Consider, on the other hand, JMeter, where, if you don’t want to do one of the supported actions (here: http://jakarta.apache.org/jmeter/usermanual/test_plan.html#samplers) , which cover, granted, everything I’d want to do in a test, then I’m not really sure what you’d do. In the example above, I was taking the value of a cookie and setting a query param based on that value, and it’s not clear to me how I’d do it in JMeter.
I also don’t see POST support in JMeter, whereas The Grinder definitely has that (http://grinder.sourceforge.net/g3/script-gallery.html#fba).
Also, JMeter seems to be built for use from a single computer, though it does explicitly have support for remote agents (http://jakarta.apache.org/jmeter/usermanual/remote-test.html). The Grinder is set up from the start to have the differentiation between agent (data collector) and console (data displayer). This is a small difference.
Again, I haven’t used JMeter, this comment is just based on reading the documents at the JMeter site.
Krishna said,
April 6, 2004 at 6:00 am
We have downloaded the source code Grider3 (beta version) but the grinder.jar file is missing (the entire Lib folder itself is missing). Please suggest a solution for the problem.
Dan Moore said,
April 6, 2004 at 10:36 am
Hi Krishna,
What files did you download? I just got the grinder from this url:
http://easynews.dl.sourceforge.net/sourceforge/grinder/grinder-3.0-beta21.zip
and there’s a lib dir and a grinder.jar in it.
Dan
Sailaja said,
April 23, 2004 at 6:54 am
The following error is displayed when
java net.grinder.Grinder is given
Error initialising grinder process: net.grinder.common.GrinderException: Mandato
ry property ‘grinder.plugin’ not specified
net.grinder.common.GrinderException: Mandatory property ‘grinder.plugin’ not spe
cified
at net.grinder.common.GrinderProperties.getMandatoryProperty(GrinderProp
erties.java:159)
at net.grinder.engine.process.GrinderProcess.instantiatePlugin(GrinderPr
ocess.java:253)
at net.grinder.engine.process.GrinderProcess.(GrinderProcess.java:
215)
at net.grinder.engine.process.GrinderProcess.main(GrinderProcess.java:10)
The Grinder version 2.8.6 finished
Inputs reqd?
roobeast said,
April 27, 2004 at 12:09 pm
Jmeter does have POST support. It’s selectable on the HTTPRequest component. I have been able to get jmeter to do pretty reasonable stuff like hit a home page, log in as a user with a post, cycle through some account history pages using regexes to pull out urls. You can then loop all this with different users. I’m interested in taking a look at grinder.
windy said,
May 12, 2004 at 10:01 am
Hi Roobeast
Could you please tell me how you “loop all this with DIFFERENT USERS”?
Thanks a lot
TP said,
July 6, 2004 at 9:34 am
same problem as sailajabatchu@yahoo.com
Mandatory property ‘grinder.plugin’ not specified
any hints?
Dan Moore said,
July 7, 2004 at 9:05 pm
Hi TP,
So, there’s a file called grinder.properties that needs to be in the classpath of the agent scripts. For the Grinder v3 (which is what I used) I didn’t have to have a grinder.plugin property, but I did have to have the grinder.properties file. If you’re using v2, perhaps http://grinder.sourceforge.net/manual/properties.html will help you out. From http://grinder.sourceforge.net/manual/http-plugin.html, it looks like the grinder.plugin property needs to be set to net.grinder.plugin.http.HttpPlugin
Rodrigo said,
July 23, 2004 at 3:16 am
Where does the grinder.propeties file nedd to be placed ???
I think it is not finding it when running the agent.
alex said,
August 4, 2004 at 10:07 pm
I am using grinder2.8.1 aftr getting into a mess trying to use jython and the plugin files. grinder2 seems to be working perfectly fine, but i am encountering a problem in hitting our test site. We r using cookies based authentication and i tried to use the HTTPSniffer for setting the username and password as post parameters. But I am always getting a ’302 redirection message’ as the output. I am displaying the output by manually inserting sops in the grinder source code. I saw something like authenticationrealm , username and pwd as grinder properties. Could you help me out in setting the correct configuration?
regards
Anticlue said,
December 12, 2004 at 9:10 am
The Grinder 3 & Web Application load testing
Web Applications have a wide range of user populations. It is not uncommon to have tens of thousand of visitors hit a site during a week. One really needs to know if the application can perform under a load and…
vidya said,
April 4, 2007 at 3:30 am
when I am running the below .py script, its not taking the values of the username and password from the file until we explicitly specifies it in the .py script.. But if we are trying to print it, its printing the values. Below is the code, so can u plz help me to find out the problem.
def page2(self):
“”"POST index.jsp (request 201).”"”
tre = TestRandomise(“users.txt”)
(user,passwd) = tre.getUserInfo()
#user = ‘aa’
#passwd = ‘a’
result = request201.POST(‘/purchase/Jsp/Common/index.jsp’,
( NVPair(‘dummy_username’, user),
NVPair(‘dummy_password’, passwd),
NVPair(‘imgLogin.x’, ’0′),
NVPair(‘imgLogin.y’, ’0′), ),
( NVPair(‘Content-Type’, ‘application/x-www-form-urlencoded’), ))
# 1 different values for token_subject found in response; the first matched
# the last known value of token_subject – don’t update the variable.
self.token_j_username = \
httpUtilities.valueFromHiddenInput(‘j_username’) # ‘adt’
self.token_j_password = \
httpUtilities.valueFromHiddenInput(‘j_password’) # ‘adttest’
return result
magudapathy said,
March 12, 2008 at 10:57 am
HI,
if i want to test my application using grinder.
how can i invoke my application?
What are changes need in grinder.properties file
tal said,
January 5, 2009 at 1:35 am
can the grinder get an XML of users and password to log in with for each preccess ?
moore said,
January 5, 2009 at 9:58 am
Hi Tal,
To simulate different users for the grinder, this faq post is probably helpful (even though it just pulls the username/pw from a file):
http://grinder.sourceforge.net/faq.html#N10532
In order to do it by pulling an XML file down and then parsing it, you just need to write the python to do so (instead of from a flat file like the FAQ does). Here’s a link that might help you do that:
http://diveintopython.org/xml_processing/
Disclaimer: I have not tested any of this code.
Andruschuk Borislav said,
February 3, 2010 at 2:49 pm
You can use the GrinderStone Eclipse plugin. It allows to debug and create Grinder scripts in a fast way. You can check it out from
http://code.google.com/p/grinderstone/
mauricio cobo said,
April 15, 2010 at 10:21 pm
C:\Documents and Settings\hcoboo>java net.grinder.Grinder %GRINDERPROPERTIES%
15/04/10 05:50:53 PM (agent): The Grinder 3.4
15/04/10 05:50:53 PM (agent): connected to console at /127.0.0.1:6372
15/04/10 05:50:53 PM (agent): waiting for console signal
15/04/10 05:51:11 PM (agent): Clearing file store
15/04/10 05:51:11 PM (agent): Updating file store: “grinder.properties” (6831 by
tes)
15/04/10 05:51:11 PM (agent): Updating file store: “hugo.py” (690 bytes)
15/04/10 05:51:11 PM (agent): Updating file store: “jdbc.py” (1743 bytes)
15/04/10 05:51:13 PM (agent): received a start message
15/04/10 05:51:13 PM (agent): DEBUG MODE: Spawning threads rather than processes
AYUDA CON ESTE ERROR CUANDO USO EL JDBC.PY
15/04/10 05:51:13 PM (agent): worker SIS_CEN_006-0 started
15/04/10 05:51:15 PM (process SIS_CEN_006-0): Error running worker process (: No module named oracle
from oracle.jdbc import OracleDriver
File “C:\Documents and Settings\hcoboo\.\SIS_CEN_006-file-store\current\
jdbc.py”, line 8, in )
15/04/10 05:51:15 PM (agent): finished, waiting for console signal
mauricio cobo said,
April 15, 2010 at 10:22 pm
SI TENGO LA LIBRERIA (.JAR ) DE ORACLE ojdbc14.JAR Y NO FUNCIONA
moore said,
April 16, 2010 at 9:54 am
Hi Mauricio,
I’m not sure what you’re asking…
Sath said,
August 19, 2010 at 1:23 am
mauricio cobo says “IF I HAVE THE LIBRARY (. JAR) OF ORACLE ojdbc14.jar AND DOES NOT WORK”
Sath said,
August 19, 2010 at 1:28 am
Hi Moore,
I was trying to start Grinder 3.4. I am able to launch the console using the command “java net.grinder.Console”, but not able to run the agents. I used the command “java net.grinder.Grinder” it throws an error “Exception in thread “main” java.lang.NoClassDefFoundError: net/grinder/Grinder”. Can you please help
moore said,
August 19, 2010 at 9:02 pm
Thanks Sath.
Regarding mauricio cobo’s issue, I’m not sure why adding the oracle library into the classpath would inhibit the grinder–probably a dependency collision.
Regarding your issue, I’d check and make sure that your classpath is set correctly.
Hope this helps.