jmeter – getting started
This blog post is just a start at documenting some of my experiences with jmeter. As far as load testing tools go, jmeter looks the most promising to me. It has an active community, supports many different databases and looks quite flexible as far as architecting different work loads goes.
The flexibility of jmeter also makes it hard to use. One can use jmeter for many other things besides databases so the initial set up is a bit oblique and there look to be many paths to similar results. As such, my understand and method for doing things will probably change considerably as I start to use jmeter more and more.
I’m installing it on a mac and using RDS instances.
brew install jmeter
Database Driver download (I’m using the following)
Mysql mysql-connector-java-5.1.40-bin.jar http://ftp.iij.ad.jp/pub/db/mysql/Downloads/Connector-J/
Created a test table
CREATE TABLE authors (id INT, name VARCHAR(20), email VARCHAR(20));
INSERT INTO authors (id,name,email) VALUES(2,’foo’,’email@example.com’);
Startup up jmeter
$ which jmeter /usr/local/bin/jmeter $ jmeter Writing log file to: /Users/kylelf/jmeter.log
brings up a graphic window
Add your path to the database drivers at the bottom of the screen by clicking “Browse …” and going to your driver file and selecting it.
We are going to create the following (minimum setup for an example)
create test: Thread group named ‘Database Users’
db connection: Config element of type JDBC Connection Configuration
query to run: Sampler of type JDBC Request
results output: Listener of type “View Results Tree”
1. First to do is add a “Thread Group”
(right click on “Test Plan”)
Define how many connections to make and how many loops to make of the workload
interesting parts here are
“Number of Threads (users)” : can set the number of database connections
“Loop Count ” : can set the number of iterations of the test query
2. Add a Config Element of type JDBC Connection Configuration
Define what database to connect to
For Oracle make sure and change “Select 1″ to “Select 1 from dual” or you’ll get non-obvious error.
Name the pool. For example I call mine “orapool”
and fill out all the connection information
Database machine, port and SID of form: jdbc:oracle:thin:@yourmachine:1521:ORCL
JDBC Driver Class: oracle.jdbc.OracleDriver
3. Sampler of type JDBC Request
Define a SQL statement to run
Make sure and include the name of the thread pool created above. In my case it’s called “orapool”
add a SQL statement to run
4. Listener of type “View Results Tree”
create a widget to see the output
Final setup looks like
run your load and look at the output
Then click on “View Results Tree” to see the output.
I clicked on “View Results Tree” and then clicked on “JDBC Request” in red.
Then I’ll see some output. I choose “Response data” because it’s a bit more succinct and see the error. In this case there is an extra space ” ” at the end of “oracle.jdbc.OracleDriver “. Jmeter is sensitive to spaces. I’ve gotten a lot of errors because of spaces in fields such as variable names and such.
Correcting that it runs
All the setup might sound like a bit of a pain but once it’s set up, it’s easy to click through and make modifications.
All the setup is available in a text .jmx file and if you are brave you can edit directly there.
Here is the above example .jmx file on github.
Look for “my” and replace
The above example is more or less pointless – sort of a “Hello World”.
From here though you can increase the number of threads, increase the number of loops, add more SQL statements.
Jmeter allows a lot of customization so you can add .cvs files for input values, capture output values into variables and use them in input values, have different types of loops with different users running concurrently etc.
More to come.
Christian Antognini gave a presentation at Oaktable World SF in Sept 2016. He was gracious enough to send along his functionally rich .jmx file and I’ll blog on that soon.
NOTE: PL/SQL has to be called with “call” and not “exec” and had to be a “callable statement” type: