Neo4j节点创建速度

时间:2015-09-23 01:14:59

标签: neo4j

我的笔记本电脑上有一个全新的neo4j设置,通过REST API创建新节点似乎很慢(平均约30-40毫秒)。我已经用Google搜索了一下,但无法找到任何真正的基准,因为它应该"应该"采取;那里有this post,但这只列出了相对表现,而不是绝对表现。 neo4j本身是否仅限于每秒仅添加约30个新节点(在批处理模式之外),或者我的配置是否有问题?

配置详情:

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

2 个答案:

答案 0 :(得分:4)

Neo4j表现特征是一个棘手的领域。

测量性能

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

为了测量性能,您应该检查以下内容:

  1. 您有适当的服务器硬件(requirements
  2. 客户端和服务器位于本地网络中。
  3. Neo4j已正确配置(内存映射,Web服务器线程池,Java堆大小等)
  4. 正确配置服务器(Linux tcp堆栈,最大可用打开文件等)
  5. 服务器已预热。 Neo4j是用Java编写的,所以在测量数字之前你应该进行适当的预热(即加载约15分钟)。
  6. 最后一个 - 企业版。 Neo4j企业版具有一些可以提高性能的高级功能(即HPC cache)。

    Neo4j内部

    Neo4j内部是:

    • 存储
    • 核心API
    • 遍历API
    • Cypher API

    在没有任何其他网络请求的情况下执行所有操作。 Neo4j 服务器是建立在这个坚实基础之上的。

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

    • 客户端和服务器之间的延迟
    • JSON序列化费用
    • 网络服务器(Jetty)
    • 用于管理锁,交易等的其他模块
    • 和Neo4j本身

    所以,这里的底线是 - 如果在嵌入模式下使用,Neo4j本身相当快。但处理Neo4j服务器需要额外的费用。

    数字

    我们进行了内部Neo4j测试。我们测量了几个案例。

    创建节点

    这里我们使用的是vanilla 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  
    

    巨大的数据库同步

    这个使用自定义开发的unmanaged extension,在服务器和客户端之间使用二进制协议以及一些并发。

    但这仍然是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)。

    结果:

    $ 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能够在4ms或更短时间内创建节点(99%)。

    注意:我之前已经预热了数据库(创建并删除了100K节点)。

    螺栓

    如果您正在寻找最佳的Neo4j性能,您应该遵循 Bolt 开发。这是Neo4j服务器的新二进制协议。

    更多信息:hereherehere

答案 1 :(得分:0)

另一件要尝试的是运行./bin/neo4j-shell。由于没有HTTP连接,它可以帮助您了解Neo4j的数量以及HTTP接口的数量。

当我在2.2.2上执行此操作时,我的CREATE通常约为10毫秒。

我不确定理想是什么,以及是否有可以改善性能的配置。