neo4j bolt driver is slower than http end point

1.5k Views Asked by At

We are using http end point for read queries so far and planning to move to java bolt driver. But in initial tests it is observed that bolt driver is slower than http end point. following is the java driver code we are using.

Driver instance created at Application context level: Driver neo4jReadDriver = GraphDatabase.driver("bolt://xyz.com", AuthTokens.basic("neo4j","neo4j" ), Config.build().withMaxSessions(20).toConfig());

Application code for executing query:

    Session session = neo4jReadDriver .session();

    StatementResult result = session.run( "MATCH(p:GOE) return count(p) as cnt");


    while ( result.hasNext() )
    {
        Record record = result.next();
        System.out.println("Total number of GOEs:"+ record.get( "cnt").asInt());

    }
    result.consume();
    session.close();
    driver.close();

This query consistently takes double the time than http endpoint. Most of the time taken at driver.getSession(). Am i doing any thing wrong here? How to get high throughput using bolt java driver with concurrent users executing the read queries?

1

There are 1 best solutions below

1
On

It's unclear from your description what aspects of Bolt you are comparing with what aspects of HTTP and what metrics you are measuring. Maximum throughput? Individual query latency? And for what workload? Have you taken into account cache warming in your tests?

Given that Bolt is stateful and HTTP stateless, there is no value in including session acquisition and release in your measurements; indeed, this will skew your readings. Instead, compare only the query and result parts.