Performance Testing Neo4j database using Bolt Protocol in Apache JMeter

Show us your love by sharing this post.

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?

Bolt is a 2008 American computer animated comedyadventure film produced by Walt Disney Animation Studios and released by Walt Disney Pictures.

Bolt - animated film character
Bolt – animated film character

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.

Prerequisite

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.

  1. Download Apache JMeter 5.2 and validate the checksum
  2. 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:

  1. After downloading the zip file from the above link and extract it.
  2. Open cmd prompt and navigate to the folder where you extracted the zip contents.
  3. Change the directory to bin folder by entering the command cd bin
  4. Then enter the command neo4j.bat console as shown below and hit enter
Performance Testing Neo4j database using Bolt Protocol in Apache JMeter
Performance Testing Neo4j database using Bolt Protocol in Apache JMeter – Starting neo4j database

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.

Enter :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.

  1. Thread Group
  2. Bolt Connection Configuration (under Config Element)
  3. Bolt Request (under Sampler)
  4. 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.

Bolt Connection Configuration

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 neo4j-java-driver-1.7.5.jar in your lib folder.

Click on Bolt Request and enter the below query in Cypher Statement.

MATCH (n:Movie) RETURN n LIMIT 25

Delete the default text in the Params field.

Click on Run button and head to View Results Tree to see the result. If you to Response Body as shown, you could see the Records: Skipped

Response Body of Bolt Request
Response Body of Bolt Request

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.

Record Query Results
Record Query Results

Now we are getting the records as node which will not be very helpful. Let’s fix the cypher statement.

Bolt Request with Records
Bolt Request with Records

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.

Bolt Request Response with Movie names
Bolt Request Response with Movie names

Important Note: You need to use Record Query Results as true only 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)

GitHub Repository

Please check my GitHub repository for the sample Bolt test plan.

Conclusion

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

2 thoughts on “Performance Testing Neo4j database using Bolt Protocol in Apache JMeter”

  1. Sir, I wanted to do load testing on a rest api , that is used to insert data into Neo4j db. Do you know a way to do this using jmeter ?

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

New Year. New Hope. Learn TruWeb. 78% OFF for Limited Time of my Udemy course..BUY NOW
× How can I help you?