pur*_*ion 2 performance ram neo4j cypher
我有一个Neo4J企业数据库,运行在具有8Gb RAM和80Gb SSD的DigitalOcean VPS上.Neo4J实例的性能目前很糟糕:
match (n) where n.gram='0gram' AND n.word=~'a.' return n.word LIMIT 5 @ 349ms
match (n) where n.gram='0gram' AND n.word=~'a.*' return n.word LIMIT 25 @ 1588ms
Run Code Online (Sandbox Code Playgroud)
我理解正则表达式是昂贵的,但在同样的查询,我用任何其他字母替换'a.'
或'a.*'
部分,Neo4j只是崩溃.在此之前我可以看到内存中的大量增加(达到90%),并且CPU飙升.
我的Neo4j填充如下:
Number Of Relationship Type Ids In Use: 1,
Number Of Node Ids In Use: 172412046,
Number Of Relationship Ids In Use: 172219328,
Number Of Property Ids In Use: 344453742
Run Code Online (Sandbox Code Playgroud)
VPS只运行Neo4J(在debian 7/amd64上).我使用NUMA + parallelGC标志,因为它们应该更快.我一直在调整我的RAM设置,虽然现在经常没有崩溃,但我觉得应该有一些收获
neostore.nodestore.db.mapped_memory=1024M
neostore.relationshipstore.db.mapped_memory=2048M
neostore.propertystore.db.mapped_memory=6144M
neostore.propertystore.db.strings.mapped_memory=512M
neostore.propertystore.db.arrays.mapped_memory=512M
# caching
cache_type=hpc
node_cache_array_fraction=7
relationship_cache_array_fraction=5
# node_cache_size=3G
# relationship_cache_size=1G --> these throw a not-enough-heap-mem error
Run Code Online (Sandbox Code Playgroud)
数据本质上是一系列树,其中node0
仅需要全文搜索,具有浮点值的属性搜索以下节点.
node0 -REL-> node0.1 -REL-> node0.1.1 ... node0.1.1.1.1
\
-REL-> node0.2 -REL-> node0.2.1 ... node0.2.1.1
Run Code Online (Sandbox Code Playgroud)
有aprox.5.000个顶级节点node0
.
我应该重新配置我的内存/缓存使用情况,还是应该添加更多内存?
---编辑索引---
因为所有树的节点总是4层深,所以每个层都有一个标签可以快速查找.在这种情况下,所有node0
节点都有一个标签(称为0gram
).在n.gram='0gram'
应该使用耦合到所述标签的索引.
---编辑新的配置---
我将VPS升级到16Gb.nodeStore具有2.3Gb(11%),PropertyStore 13.8Gb(64%),SSD上的relastionshipStore达到5.6Gb(26%).在此基础上,我创建了一个新的配置(详见上文).我正在等待全套查询,并会在同一时间进行一些额外的测试
是的你需要创建一个索引,你的标签叫什么?想象一下它被召唤:NGram
create index on :NGram(gram);
match (n:NGram) where n.gram='0gram' AND n.word=~'a.' return n.word LIMIT 5
match (n:NGram) where n.gram='0gram' AND n.word=~'a.*' return n.word LIMIT 25
Run Code Online (Sandbox Code Playgroud)
你正在做的不是图搜索,而只是通过全扫描查找+与正则表达式进行属性比较.不是一个非常有效的操作.您需要的是FullTextSearch(新模式索引不支持,但仍然使用旧索引).
您可以运行此查询(在创建索引之后)并说明它返回了多少个节点?
match (n:NGram) where n.gram='0gram' return count(*)
Run Code Online (Sandbox Code Playgroud)
这相当于
match (n:NGram {gram:'0gram'}) return count(*)
Run Code Online (Sandbox Code Playgroud)
我几天前写了一篇关于它的博客文章,请阅读它,看它是否适用于你的案例.
你的Neo4j数据库在磁盘上有多大?配置的堆大小是多少?(在neo4j-wrapper.conf
?)
正如您所看到的,您使用的内存比机器多(甚至不计算操作系统或文件系统缓存).
因此,您必须减小mmio大小,例如,对于rels为节点2G为500M,对于属性为1G.
查看商店文件大小并相应地设置mmio.