Node.js Neo4J可以处理多少并行连接
我们正在尝试从多个nodejs进程访问neo4jgraph数据库服务器。每个进程都在创建自己的连接,并尝试连接/写入neo4j数据库。我们尝试了大约10个进程,但它无法处理这么多的连接 鉴于此,所有连接都具有高工作负载 有谁能建议Neo4J DB可以使用多少个并行连接,以及如何扩展以支持更多连接 编辑:更多信息 使用“neo4j”npm包创建连接,如下所示:Node.js Neo4J可以处理多少并行连接,node.js,neo4j,database-connection,graph-databases,Node.js,Neo4j,Database Connection,Graph Databases,我们正在尝试从多个nodejs进程访问neo4jgraph数据库服务器。每个进程都在创建自己的连接,并尝试连接/写入neo4j数据库。我们尝试了大约10个进程,但它无法处理这么多的连接 鉴于此,所有连接都具有高工作负载 有谁能建议Neo4J DB可以使用多少个并行连接,以及如何扩展以支持更多连接 编辑:更多信息 使用“neo4j”npm包创建连接,如下所示: var neo4j = require('neo4j') var config = require('./config') var gra
var neo4j = require('neo4j')
var config = require('./config')
var graph = new neo4j.GraphDatabase(config.db.neo4j)
//usage
graph.query(query, params, function(err, result){
//
})
我假设对于每个进程,这段代码都在创建新的连接(“graph”变量的每个实例),因为显然没有任何池机制
我假设基于生成的nodejs进程的连接数(所有进程都是单线程的)。不确定这是否有帮助,但如果您希望执行并发读/写,因此没有限制。 但是,你需要考虑的主要问题是你想执行的操作。如果您执行的是简单的读/写操作,并且成本不高,那么与您希望执行更繁重的操作时相比,您可以获得更多的并发请求 例如,前一段时间我试图并行运行5-6个图形查询,结果导致服务器崩溃。
另一方面,我现在使用的一些脚本并行运行近50-100个查询,没有问题。我也有同样的问题。尝试使用
@qualitech/Qneo4j
npm软件包进行连接
尝试使用false
更改参数autoclosedriver
const QNeo4j = require('@qualitech/qneo4j')
// simplest
const db = new QNeo4j({
url: 'bolt://localhost:7687'
})
// full options
const db = new QNeo4j({
url: 'bolt://localhost:7687',
username: 'neo4j', // default: 'neo4j'
password: 'admin', // default: 'admin'
// description: if true, returns raw value of the Neo4j.
raw: false, // default: false,
// description: closes the Neo4j driver after the execute method or transaction.
autoCloseDriver: true, // default: true
// description: expects to receive a callback function. This callback is called every time an error occurs within the QNeo4j module.
notifyError: (error, query) => console.log(error, query),
// description: all configuration available to the driver Neo4j can be set here. See more https://neo4j.com/docs/driver-manual/current/client-applications/
driverConfig: {
// ... neo4j driver configuration
}
})
在driverConfig
中使用示例
{
maxConnectionLifetime: 3 * 60 * 60 * 1000, // 3 hours
maxConnectionPoolSize: 50,
connectionAcquisitionTimeout: 2 * 60 * 1000 // 120 seconds
connectionTimeout:
maxTransactionRetryTime:
}
一根绳子有多长?对不起,我不知道你的意思。你能详细说明一下你想知道什么吗?拉娜,请提供详细信息,说明他们正在建立什么样的联系,以及你看到的什么症状让你说“无法处理这么多的联系”。你是怎么测量它是10的?您在这里提供的内容很少,在您提供更多内容之前,无法回答此问题。您看到的错误消息到底是什么?您的代码仍然没有指定连接方式。require(“redis”)表示您使用的是redis,而不是neo4j,这是一个不同的数据库。