Using JMeter to Performance Test Web Services
Pages: 1, 2, 3, 4, 5

Testing databases

Evaluating database server performance is another feature supported by JMeter. You have a choice of using the JDBC Request element provided by the software or of creating your own test using either a script or Java class. For example, you could test calls to stored procedures using something similar to the examples shown before. Many database-tuning techniques are available that include using vendor-specific optimization such as parallel processing of queries, using joins, or indexing. Moreover, knowledge of data organization is useful when creating queries with multiple boolean evaluations. Database and query tuning are particularly critical in applications dealing with large amounts of data, and, JMeter is a tool that is capable of providing some metrics in such evaluations. For example, you can execute performance or load tests before and after data or query optimization and compare results.

Let us demonstrate how the simple database performance measurement plan works by creating a test plan for a MySQL instance. First, download a JDBC driver from the MySQL Web site and copy it into /lib directory so JMeter is able to access a database. Now start JMeter, create a thread group, and set the loop count and the number of threads accordingly. Add JDBC Connection Configuration, JDBC Query Defaults, and JDBC Request elements. In these dialogs we need to configure the database connectivity and query. Enter the database URL value, which will look something like jdbc:mysql://hostname/databaseName, and enter com.mysql.jdbc.Driver for the JDBC Driver Class. For our experiment a database customers was created with a table customer that has three fields: name, address, and account. Type in a query in a Query box, for example select name from customer.

To visualize the results you may add either a chart with a response time or a response assertion if you want to verify that the response matches a certain pattern. For example, in Response Assertion add a text pattern "Smith." The Assertion Result window will show an error such as "Test failed, text expected to contain /Smith/," or "Response was null" if we have no connection due to errors in settings. Nothing will be returned if the test was successful. In addition to chart and assertion listeners we may use an Aggregate Report that summarizes the number of samples, average, median, throughput in a table.


JMeter is a flexible tool that not only allows you to test the HTTP servers but also to load-test Web services. A skilled developer can write their own scripts to simulate or customize the client requests or add a customized visualization of test results. Web service and SOAP samplers are new features of JMeter; hopefully they will evolve as Web services get a wider acceptance in industry and among developers.

Using the existing functionality of JMeter and its provided user interface we were able to simulate a load of 5 concurrent threads hitting the server with 10 and 5 ms delays. This tutorial demonstrated how the tool can be used for measuring the response time of Web services. Utilizing JMeter scripting, for example, we can address client authentication and authorization. Both the tested application server and JMeter client were physically installed on the same workstation, however the same setup can be used for testing remote servers.

The results and charts presented do not yet provide a valuable performance report; they only illustrate a plain distribution of WebLogic Server response time to Web service requests. To get an idea of whether an optimization was achieved, the same load test should be run before and after optimization, or against two different servers, or using different loads with a variable number of clients-threads. In other words, only the comparative results have value and help to understand server performance which then allows conclusions based on these metrics.


Dmitri Nevedrov works as a software engineer (at BEA systems) and is based in Denver, Colorado.