简体   繁体   English

Neo4j性能Neo4j REST API与Neo4j Java驱动程序

[英]Neo4j performance Neo4j REST API Vs Neo4j Java Driver

Our current implementation has all calls to Neo4j through REST API. 我们当前的实现通过REST API调用了Neo4j。 We are in process of replacing some of the code through neo4j-java-driver. 我们正在通过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. 我们遇到了一些性能问题,我们试图通过Cypher优化以及将负载从Neo4j DB转移到应用程序层来解决。 Using java driver, will it further reduce load on Neo4j DB or will just help in terms of reducing network latency? 使用Java驱动程序,它会进一步减少Neo4j DB的负载还是在减少网络延迟方面有所帮助?

The driver is a bit more optimal for some things. 在某些方面,驱动程序更理想。 Version 1.5 will also allow async operations. 1.5版还将允许异步操作。 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. 它不再需要生成JSON,而是将流式传输二进制协议。 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. Windows,带有16GB RAM,100K个节点,本地连接到Neo4j。

String defaultNodes = "1000"; 字符串defaultNodes =“ 1000”;

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

String query = "MATCH (n) return n LIMIT "+defaultNodes; 字符串查询=“ MATCH(n)返回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 C:\\迁移> java -jar neo4jtestexamples-1.0.0-SNAPSHOT-jar-with-dependencies.jar

With bolt for LIMIT 1000 -- 131 带限位螺栓1000-131

With REST for LIMIT 1000 -- 162 REST适用于LIMIT 1000-162

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

With bolt for LIMIT 1000 -- 143 带限位螺栓1000-143

With REST for LIMIT 1000 -- 156 REST限制为1000-156

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

With bolt for LIMIT 10000 -- 377 带限位螺栓10000-377

With REST for LIMIT 10000 -- 156 REST限制为10000-156

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

With bolt for LIMIT 10000 -- 335 带限位螺栓10000-335

With REST for LIMIT 10000 -- 157 REST限制为10000-157

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

With bolt for LIMIT 1000 -- 104 带限位螺栓1000-104

With REST for LIMIT 1000 -- 161 REST限制为1000-161

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

With bolt for LIMIT 25000 -- 595 带限位螺栓25000-595

With REST for LIMIT 25000 -- 155 REST限制为25000-155

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

With bolt for LIMIT 25000 -- 544 带限位螺栓25000-544

With REST for LIMIT 25000 -- 151 使用REST时限为25000-151

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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