Use jMeter for performance test
Recently I developed performance test for a financial application with jMeter, and found it quite a useful tool. It is able to
Inject N number of deals into message queue such as Kafka or active MQ
Initiate HTTP requests to call backend and UI APIs N times
Initiate JDBC request to run SQL queries in database N times
Assert results in the responses of http and jdbc requests
Give performance data for N times of requests
So I am able to measure to duration needed for the application to process 1000 messages. And have data to draw such plot about application performance (number of messages vs processing time in seconds)
Experiences / Tips
1. Use number of threads in a thread group to control the number of execution.
2. Use CSV data set config to load data from file into variable.
3. Use user defined variable to define a variable
4. Use http request sampler to make http api call
5. use http header manager to provide header for api call
6. use BeanShell PostProcessor to execute some logic programmatically after the http request, such as writing variables to a file.
- use view results tree to view http call request and response data
8. use setUp thread group as a pre step to set up data and env for main thread group
use tearDown thread group to run post-test steps such as querying database for trades created
- use constant timer to pause before the next http request.
It add a pause between every requests in a thread group.
10. use regular expression extractor to extract a token from http response header
11. use JDBC connection configuration to connect to Application Database
need to put mariaDB driver jar file (found in .m2 folder) in jmeter lib folder
12. use JDBC Request to run a SQL query to the DB
View the result in view results tree
If you want to plot the result of a database query directly within JMeter, unfortunately, JMeter doesn't have built-in capabilities to directly plot database query results.
13. use Response Assertion to assert that the response of a DB request contains certain value.
It will fail if the response is not as expected.
14. use Run Thread Group Consecutively and Startup Delay to start one thread group certain time later than another thread group.
15. uncheck Functional Test Mode to not affect performance
16. to use a value in a jdbc response in the next http request
a. set result variable name in the JDBC Request
b. then use JSR223 PreProcessor in the next request to extract the value in the response key value pair.
17. to view the performance results of multiple http requests
use summary report and graph results
18. to create a running number for each thread run, to indicate different e.g. trade id, use counter
Subscribe to my newsletter
Read articles from joseph directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by