Performance Testing Neo4j database using Bolt Protocol in Apache JMeter | Apache JMeter 5.2 is out now. You can check out my article here. If you prefer video format, you can check it out my YouTube channel. New protocol called Bolt has been introduced in this newer version of JMeter to test the Neo4j database using cypher queries. This blog post helps you to get started with performance test scripting bolt protocol in Apache JMeter 5.2.
Here is my YouTube video which gives you an overview about what’s new in Apache JMeter.
What is Bolt?
No, I am not talking about your favorite character from the feature film Bolt 🙂 I am talking about Bolt Protocol.
What is Bolt Protocol?
Bolt is light weight client-server protocol designed for database applications. Client will be sending out the queries basically a statement with parameters and the server will respond to the query.
Bolt Protocol originally authored by Neo4j graph database team. You can check it out https://boltprotocol.org/ for more details.
The recommended default port of bolt is 7687 which communicates over TCP or WebSocket connection.
If your project has Neo4j, you can use the credentials directly in JMeter and test your queries which we are going to see it in a moment. But those who do not have Neo4j, please read on. Others, you can skip this section and download only Apache JMeter 5.2.
- Download Apache JMeter 5.2 and validate the checksum
- Neo4j Community Edition and validate the checksum
The version Neo4j which we are going to use is 3.5.12 for Windows OS.
How to install Neo4j Community Edition in Windows OS?
Follow the below steps to install Neo4j Community Edition in Windows 10:
- After downloading the zip file from the above link and extract it.
cmdprompt and navigate to the folder where you extracted the zip contents.
- Change the directory to bin folder by entering the command
- Then enter the command
neo4j.bat consoleas shown below and hit enter
Neo4j is up and running at
http://localhost:7474 by default.
Launch the Neo4j in your favorite browser. When you login first, you need to enter the default credentials neo4j/neo4j and it will prompt you to change the default credentials.
Now, let’s load up some demo data to Neo4j.
:play movies command and hit the run button as shown below.
Click on the right arrow as shown below.
It will display the CREATE code block, you need to click on it which will paste the code to the query box, then you need to hit enter. This will create demo data for you to play.
Below is the demo data which is ready for us to play with JMeter.
Performance Testing Neo4j database
I assume that you have some experience in JMeter by creating a Thread Group, adding HTTP Requests, View Results Tree.
Download JMeter 5.2, Extract the zip file, and launch JMeter by navigating to
bin > jmeter.bat
Add the below elements to the Test Plan.
- Thread Group
- Bolt Connection Configuration (under Config Element)
- Bolt Request (under Sampler)
- View Results Tree (under Listener)
Save the test plan with a valid name.
In Bolt Connection Configuration element, you need to enter your Neo4j URI and credentials.
Important Note: The Console port number is 7474, but the Bolt communicates over 7687.
We are all set to send the cypher queries using Bolt Request. Let us retrieve 25 Movie names from the Neo4j database.
Tip : You could find the
Bolt Request and enter the below query in
MATCH (n:Movie) RETURN n LIMIT 25
Delete the default text in the
Run button and head to
View Results Tree to see the result. If you to
Response Body as shown, you could see the
That is because in the
Bolt Request default value for
Record Query Results set to
false. Let us set the flag to
true and re-run the test plan.
Now we are getting the records as node which will not be very helpful. Let’s fix the cypher statement.
Use the below cypher statement in the Bolt Request and execute again.
MATCH (n:Movie) return n.title limit 25
Now you can see the actual movie names as shown below.
Important Note: You need to use
Record Query Resultsas
trueonly for unit testing. If you enable it during the load test, it will cause memory overhead. Use it wisely.
Every bolt request uses a connection from the pool, at this moment the connection pool size is 100 which is not configurable.
If you add the
Aggregate Report, the response time is the round trip time between the cypher query execution time and the time to consume the results to send back.
Bolt Request Response Time = (Cypher Query Execution Time + Results Processing Time to send back)
Please check my GitHub repository for the sample Bolt test plan.
By leveraging Bolt Request Sampler in Apache JMeter 5.2 you can easily send cypher statement to test the Neo4j graph database. The Bolt Request sampler is not matured enough where you cannot configure the pool size. But eventually, it will mature enough to test the graph database.
Image Credit for Bolt from Wikipedia