小图的Neo4J在Ubuntu 16.04上使用了大量的内存
我已经在具有8GB和4核的Ubuntu 16.04虚拟机(Hyper-V)中安装了Neo4J v3.3.0(社区版)。
我有一个非常小的图(30节点),它只是用于阅读(每3秒约1次),它很less被写入。 我们想要扩展更多的图表,但是每三天(有时候会less一些)我们的服务器崩溃,因为Java占用了2GB以上的空间,而且顶部显示了300%的CPU使用率。
对我来说这是没有意义的,请问我可以让我知道如何configurationJava或Neo4J,以防止这种情况?
谢谢
我在/etc/neo4j/neo4j.conf
文件中有以下configuration:
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
发生这种情况时,日志文件显示以下错误:
ERROR [onbvrcRunnableBoltWorker] Worker for session 'ecfe4a7f-1714-4ba3-9e98-a692bf153b45' crashed. Java heap space java.lang.OutOfMemoryError: Java heap space
也有这些可疑的消息(有很多):
WARN [onkicMonitorGc] GC Monitor: Application threads blocked for 4680ms. ERROR [onbvtBoltMessagingProtocolV1Handler] 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
新的信息
我做了一个:
netstat -an | grep ESTABLISHED
我有很多开放的连接。 我们在nodeJS( https://github.com/neo4j/neo4j-javascript-driver )中使用以下javascript驱动程序。 将检查我们是否没有正确地检查连接。
看来我正确地closures正确的所有连接:
session.close(); driver.close();
在我退出应用程序之前,连接仍然保持打开状态。
最终评论
我的代码中有一个地方没有closures连接。
https://github.com/neo4j/neo4j-javascript-driver/issues/275
我可以说,Neo4j在8GB的RAM上有10mln的节点和30ml的关系,没有特别的调整,对我来说工作的很好。
顶部显示垃圾收集完成后可能会有300%的CPU使用率。 所以我投票增加堆大小
/etc/neo4j/neo4j.conf
参数
dbms.memory.heap.max_size=3g
在较大的数据库上,高CPU消耗意味着没有索引。
要列出索引:
CALL db.indexes();
创造一个:
CREATE INDEX ON :Label(prop_name);
如果你得到了OOM错误(见dmesg),并且java被linux杀死(不是崩溃),尝试安装服务器操作系统,就像没有GUI和c的CentOS一样,释放一些内存。 对于8-10GB大小的数据库,8GB对于Neo4j已经足够了。