[英]Neo4J with small graph uses a lot of memory on Ubuntu 16.04
I have installed Neo4J v3.3.0 (community edition) in an Ubuntu 16.04 virtual machine (Hyper-V) with 8GB and 4 cores. 我已经在具有8GB和4个内核的Ubuntu 16.04虚拟机(Hyper-V)中安装了Neo4J v3.3.0(社区版)。
I have a very small graph (30 nodes) and it is used just for reading (about 1 hit every 3 seconds), it seldomly gets written to. 我有一个非常小的图(30个节点),它仅用于读取(每3秒大约命中1次),很少被写入。 We want to expand the graph a lot more but every three days (sometimes less) our server crashes because Java is taking more than 2GB and top showed 300% CPU usage.
我们想扩大图表的范围,但是每三天(有时更少)我们的服务器崩溃,因为Java占用了2GB以上的内存,而top显示的CPU使用率为300%。
To me this makes no sense at all, could you please let me know how to configure Java or Neo4J in order to prevent this? 对我而言,这毫无意义,请您让我知道如何配置Java或Neo4J,以防止这种情况发生?
Thanks 谢谢
I have the following configuration in my /etc/neo4j/neo4j.conf
file: 我的
/etc/neo4j/neo4j.conf
文件中具有以下配置:
dbms.query_cache_size=5000
dbms.threads.worker_count=4
dbms.memory.heap.initial_size=2g
dbms.memory.heap.max_size=2g
dbms.memory.pagecache.size=2g
The log files show the following error when this happens: 发生这种情况时,日志文件显示以下错误:
ERROR [o.n.b.v.r.c.RunnableBoltWorker] Worker for session 'ecfe4a7f-1714-4ba3-9e98-a692bf153b45' crashed. Java heap space java.lang.OutOfMemoryError: Java heap space
There are also these suspicious messages (which there are a lot of): 也有这些可疑消息(有很多):
WARN [o.n.k.i.c.MonitorGc] GC Monitor: Application threads blocked for 4680ms.
ERROR [o.n.b.v.t.BoltMessagingProtocolV1Handler] Failed to write response to driver Unable to write to the closed output channel org.neo4j.bolt.v1.packstream.PackOutputClosedException: Unable to write to the closed output channel
WARN [io.netty.channel.DefaultChannelPipeline] An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception. syscall:read(..) failed: Connection reset by peer
New Information 新的信息
I did an: 我做了一个:
netstat -an | grep ESTABLISHED
I had a lot of open connections. 我有很多开放的联系。 We are using the following javascript driver in nodeJS ( https://github.com/neo4j/neo4j-javascript-driver ).
我们在nodeJS( https://github.com/neo4j/neo4j-javascript-driver )中使用以下javascript驱动程序。 Will check if we are not properly checking connections.
将检查我们是否没有正确检查连接。
It seems I am closing correctly all connections properly with: 看来我正确地使用以下命令正确关闭了所有连接:
session.close();
driver.close();
The connections still remain open until I exit the application. 在我退出应用程序之前,连接仍保持打开状态。
Final Comments 最后评论
There was a place in my code where I was not closing connections. 我的代码中有一个我没有关闭连接的地方。
https://github.com/neo4j/neo4j-javascript-driver/issues/275 https://github.com/neo4j/neo4j-javascript-driver/issues/275
I can say, that Neo4j works fine for me on 8GB of RAM with 10mln nodes and 30mln relations without special tuning. 我可以说,Neo4j可以在8GB的RAM(具有10m节点和30m的关系)上运行而无需特殊调整。
top shows 300% CPU usage probably when garbage collection is done. top显示可能在完成垃圾收集后300%的CPU使用率。 So I vote for increasing heap size
所以我投票赞成增加堆大小
/etc/neo4j/neo4j.conf
parameter 参数
dbms.memory.heap.max_size=3g
On larger databases high CPU consumption mean absence of indexes. 在较大的数据库上,高CPU使用量意味着没有索引。
To list indexes: 列出索引:
CALL db.indexes();
to create one: 创建一个:
CREATE INDEX ON :Label(prop_name);
If you get OOM errors (see dmesg) and java gets killed by linux (not crashes), try to install server OS, like CentOS without GUI et c, to free some memory. 如果出现OOM错误(请参阅dmesg),并且java被linux杀死(不会崩溃),请尝试安装服务器OS,例如不带GUI等的CentOS ,以释放一些内存。 8GB is more than enough for Neo4j with 8-10GB size database.
对于具有8-10GB大小数据库的Neo4j,8GB绰绰有余。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.