我的笔记本电脑上有一个全新的neo4j设置,通过REST API创建新节点似乎很慢(平均约30-40毫秒).我用Google搜索了一下,但找不到任何真正的基准,因为它应该花多长时间; 有这个职位,但只列出了相对业绩,而不是绝对的性能.neo4j固有地限于每秒仅添加约30个新节点(在批处理模式之外),或者我的配置有问题吗?
配置详情:
Neo4j 性能特征是一个棘手的领域。
首先:这很大程度上取决于服务器的配置方式。在笔记本电脑上测量任何东西都是错误的方法。
在测量性能之前,您应该检查以下内容:
最后一个 - 企业版。Neo4j企业版有一些高级功能可以大大提高性能(即HPC缓存)。
Neo4j 内部是:
一切都是在没有任何额外网络请求的情况下执行的。Neo4j服务器是建立在这个坚实的基础之上的。
因此,当您向 Neo4j 服务器发出请求时,您正在测量:
所以,这里的底线是 - 如果在嵌入模式下使用,Neo4j 本身相当快。但处理 Neo4j 服务器需要额外的成本。
我们进行了内部 Neo4j 测试。我们测量了几个案例。
在这里,我们使用普通的 Transactional Cypher REST API。
线程:2
Node per transaction: 1000
Execution time: 1635
Total nodes created: 7000000
Nodes per second: 7070
Run Code Online (Sandbox Code Playgroud)
线程:5
Node per transaction: 750
Execution time: 852
Total nodes created: 7000000
Nodes per second: 8215
Run Code Online (Sandbox Code Playgroud)
这个使用定制开发的非托管扩展,在服务器和客户端之间使用二进制协议以及一些并发性。
但这仍然是 Neo4j 服务器(实际上 - Neo4j 集群)。
Node count: 80.32M (80 320 000)
Relationship count: 80.30M (80 300 000)
Property count: 257.78M (257 780 000)
Consumed time: 2142 seconds
Per second:
Nodes - 37497
Relationships - 37488
Properties - 120345
Run Code Online (Sandbox Code Playgroud)
这个数字显示了 Neo4j 真正的力量。
我现在尝试衡量性能
全新且未配置的数据库 (2.2.5),Ubuntu 14.04 (VM)。
结果:
$ ab -p post_loc.txt -T application/json -c 1 -n 10000 http://localhost:7474/db/data/node
This is ApacheBench, Version 2.3 <$Revision: 1604373 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: Jetty(9.2.4.v20141103)
Server Hostname: localhost
Server Port: 7474
Document Path: /db/data/node
Document Length: 1245 bytes
Concurrency Level: 1
Time taken for tests: 14.082 seconds
Complete requests: 10000
Failed requests: 0
Total transferred: 14910000 bytes
Total body sent: 1460000
HTML transferred: 12450000 bytes
Requests per second: 710.13 [#/sec] (mean)
Time per request: 1.408 [ms] (mean)
Time per request: 1.408 [ms] (mean, across all concurrent requests)
Transfer rate: 1033.99 [Kbytes/sec] received
101.25 kb/s sent
1135.24 kb/s total
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 19
Processing: 1 1 1.3 1 53
Waiting: 0 1 1.2 1 53
Total: 1 1 1.3 1 54
Percentage of the requests served within a certain time (ms)
50% 1
66% 1
75% 1
80% 1
90% 2
95% 2
98% 3
99% 4
100% 54 (longest request)
Run Code Online (Sandbox Code Playgroud)
这个使用 REST API 创建 10000 个节点,1 个线程中没有属性。
正如您所看到的,在我的 Linux VM 笔记本电脑上发生的事件,使用默认设置 - Neo4j 能够在 4 毫秒或更短的时间内创建节点 (99%)。
注意:我之前已经预热过数据库(创建和删除了100K节点)。
如果您正在寻找最佳的 Neo4j 性能,您应该遵循Bolt开发。这是 Neo4j 服务器的新二进制协议。