Neo4j节点创建速度快

Aly*_*nce 6 neo4j

我的笔记本电脑上有一个全新的neo4j设置,通过REST API创建新节点似乎很慢(平均约30-40毫秒).我用Google搜索了一下,但找不到任何真正的基准,因为它应该花多长时间; 有这个职位,但只列出了相对业绩,而不是绝对的性能.neo4j固有地限于每秒仅添加约30个新节点(在批处理模式之外),或者我的配置有问题吗?

配置详情:

  • Neo4j 2.2.5版
  • 服务器在我的2014年中端笔记本电脑上,运行Ubuntu 15.04
  • OpenJDK 1.8版
  • 对服务器的调用也来自我的笔记本电脑(通过localhost:7474),因此不应该涉及任何网络延迟
  • 我通过Clojure/Neocons打电话给neo4j; 使用的方法是clojurewerkz.neocons.rest.nodes类中的"create"
  • 使用Cypher似乎更慢; 例如.调用"PROFILE CREATE(你:Person {name:"Jane Doe"})返回"通过HTML界面返回"Cypher版本:CYPHER 2.2,planner:RULE.5毫秒总命中率54毫秒."

Fyl*_*mTM 5

Neo4j 性能特征是一个棘手的领域。

衡量绩效

首先:这很大程度上取决于服务器的配置方式。在笔记本电脑上测量任何东西都是错误的方法。

在测量性能之前,您应该检查以下内容:

  1. 您有适当的服务器硬件(要求
  2. 客户端和服务器都在本地网络中。
  3. Neo4j 已正确配置(内存映射、Web 服务器线程池、Java 堆大小等)
  4. 服务器配置正确(Linux tcp 堆栈、最大可用打开文件数等)
  5. 服务器已预热。Neo4j 是用 Java 编写的,因此您应该在测量数字之前进行适当的预热(即进行约 15 分钟的负载)。

最后一个 - 企业版。Neo4j企业版有一些高级功能可以大大提高性能(即HPC缓存)。

Neo4j 内部

Neo4j 内部是:

  • 贮存
  • 核心API
  • 遍历API
  • 密码API

一切都是在没有任何额外网络请求的情况下执行的。Neo4j服务器是建立在这个坚实的基础之上的。

因此,当您向 Neo4j 服务器发出请求时,您正在测量:

  • 客户端和服务器之间的延迟
  • JSON 序列化成本
  • 网络服务器(码头)
  • 用于管理锁、事务等的附加模块
  • 还有 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 服务器的新二进制协议。

更多信息:这里这里这里