简体   繁体   中英

Neo4j performance Neo4j REST API Vs Neo4j Java Driver

Our current implementation has all calls to Neo4j through REST API. We are in process of replacing some of the code through neo4j-java-driver. We had some issues with performance which we tried to resolve through Cypher optimization and moving load from Neo4j DB to application layer. Using java driver, will it further reduce load on Neo4j DB or will just help in terms of reducing network latency?

The driver is a bit more optimal for some things. Version 1.5 will also allow async operations. The next major version will also provide backpressure and reactive operations.

It doesn't have to generate JSON anymore but will stream a binary protocol. So that might reduce the load a bit. I'm not sure, it will have a lot of impact.

Best to measure yourself.

I did some testing and below are the results, which are not very encouraging

Windows with 16GB RAM, 100K nodes with local connecting to Neo4j.

String defaultNodes = "1000";

    if(args.length > 0) {
        defaultNodes = args[0];
    }

String query = "MATCH (n) return n LIMIT "+defaultNodes;

        long time = System.currentTimeMillis();

        session.run(query);

        System.out.println("With bolt for LIMIT "+defaultNodes+" -- "+(System.currentTimeMillis() - time));

        time = System.currentTimeMillis();

        Neo4jRESTHandler dbHandler = new Neo4jRESTHandler();
        dbHandler.executeCypherQuery(query);

        System.out.println("With REST for LIMIT "+defaultNodes+" -- "+(System.currentTimeMillis() - time));

C:\\Migration>java -jar neo4jtestexamples-1.0.0-SNAPSHOT-jar-with-dependencies.jar

With bolt for LIMIT 1000 -- 131

With REST for LIMIT 1000 -- 162

C:\\Migration>java -jar neo4jtestexamples-1.0.0-SNAPSHOT-jar-with-dependencies.ja r

With bolt for LIMIT 1000 -- 143

With REST for LIMIT 1000 -- 156

C:\\Migration>java -jar neo4jtestexamples-1.0.0-SNAPSHOT-jar-with-dependencies.ja r 10000

With bolt for LIMIT 10000 -- 377

With REST for LIMIT 10000 -- 156

C:\\Migration>java -jar neo4jtestexamples-1.0.0-SNAPSHOT-jar-with-dependencies.ja r 10000

With bolt for LIMIT 10000 -- 335

With REST for LIMIT 10000 -- 157

C:\\Migration>java -jar neo4jtestexamples-1.0.0-SNAPSHOT-jar-with-dependencies.ja r

With bolt for LIMIT 1000 -- 104

With REST for LIMIT 1000 -- 161

C:\\Migration>java -jar neo4jtestexamples-1.0.0-SNAPSHOT-jar-with-dependencies.ja r 25000

With bolt for LIMIT 25000 -- 595

With REST for LIMIT 25000 -- 155

C:\\Migration>java -jar neo4jtestexamples-1.0.0-SNAPSHOT-jar-with-dependencies.ja r 25000

With bolt for LIMIT 25000 -- 544

With REST for LIMIT 25000 -- 151

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM