Neo4j 性能特征是一个棘手的领域。
测量性能
首先:这一切都取决于a lot关于如何配置服务器。在笔记本电脑上测量任何东西都是错误的方法。
在测量性能之前,您应该检查以下内容:
- 您有适当的服务器硬件(要求 http://neo4j.com/docs/stable/deployment-requirements.html)
- 客户端和服务器都在本地网络中。
- Neo4j 已正确配置(内存映射、Web 服务器线程池、Java 堆大小等)
- 服务器配置正确(Linux tcp 堆栈、最大可用打开文件数等)
- 服务器已预热。 Neo4j 是用 Java 编写的,因此您应该在测量数字之前进行适当的预热(即进行约 15 分钟的负载)。
最后一个 - 企业版。 Neo4j企业版有一些高级功能,可以大大提高性能(即高性能计算缓存 http://neo4j.com/docs/stable/configuration-caches.html).
Neo4j 内部
Neo4j 内部是:
- Storage
- Core API
- 遍历API
- 密码API
一切都是在没有任何额外网络请求的情况下执行的。新4jserver是建立在这个坚实的基础之上的。
因此,当您向 Neo4j 服务器发出请求时,您正在测量:
- 客户端和服务器之间的延迟
- JSON 序列化成本
- 网络服务器(码头)
- 用于管理锁、事务等的附加模块
- 还有 Neo4j 本身
所以,这里的底线是 - 如果在嵌入模式下使用,Neo4j 本身相当快。但处理 Neo4j 服务器需要额外的成本。
Numbers
我们进行了内部 Neo4j 测试。我们测量了几个案例。
创建节点
在这里,我们使用普通的 Transactional Cypher REST API。
线程:2
Node per transaction: 1000
Execution time: 1635
Total nodes created: 7000000
Nodes per second: 7070
线程:5
Node per transaction: 750
Execution time: 852
Total nodes created: 7000000
Nodes per second: 8215
庞大的数据库同步
这个使用定制开发的非托管扩展 http://neo4j.com/docs/stable/server-unmanaged-extensions.html,服务器和客户端之间采用二进制协议以及一定的并发性。
但这仍然是 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
这个数字显示了 Neo4j 真正的力量。
我的号码
我现在尝试衡量性能
全新且未配置的数据库 (2.2.5),Ubuntu 14.04 (VM)。
Results:
$ 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)
这个使用 REST API 创建 10000 个节点,1 个线程中没有属性。
正如您所看到的,在我的 Linux VM 笔记本电脑上发生的事件,使用默认设置 - Neo4j 能够在 4 毫秒或更短的时间内创建节点 (99%)。
Note:我之前已经预热过数据库(创建和删除了100K节点)。
Bolt
如果您正在寻找最佳的 Neo4j 性能,您应该遵循Bolt发展。这是 Neo4j 服务器的新二进制协议。
更多信息:here https://github.com/neo4j/neo4j-java-driver, here https://github.com/neo4j/neo4j-java-driver and here http://alpha.neotechnology.com.s3-website-eu-west-1.amazonaws.com/.