在Neo4J中创建节点的吞吐量随着属性数量的增加而显著降低
我正在进行A/B测试,以测量在Neo4J中创建节点的吞吐量。我发现创建节点的吞吐量随着属性数量的增加而显著降低 设置:Neo4j cluster 3.5.7(3个核心实例,其中一个是领导者,其余两个是追随者) TestA:用于测量在Neo4j中创建节点的吞吐量,其中每个节点有20个属性 TestB:用于测量在Neo4j cluster 3.5.7中创建节点的吞吐量,其中每个节点有40个属性 结果:TestB的吞吐量=1/2*TestA的吞吐量 下面是我用来生成负载和测量吞吐量的代码在Neo4J中创建节点的吞吐量随着属性数量的增加而显著降低,neo4j,Neo4j,我正在进行A/B测试,以测量在Neo4J中创建节点的吞吐量。我发现创建节点的吞吐量随着属性数量的增加而显著降低 设置:Neo4j cluster 3.5.7(3个核心实例,其中一个是领导者,其余两个是追随者) TestA:用于测量在Neo4j中创建节点的吞吐量,其中每个节点有20个属性 TestB:用于测量在Neo4j cluster 3.5.7中创建节点的吞吐量,其中每个节点有40个属性 结果:TestB的吞吐量=1/2*TestA的吞吐量 下面是我用来生成负载和测量吞吐量的代码 import
import org.neo4j.driver.v1.*;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
public class UnwindCreateNodes {
Driver driver;
static int start;
static int end;
public UnwindCreateNodes(String uri, String user, String password) {
Config config = Config.build()
.withConnectionTimeout(10, TimeUnit.SECONDS)
.toConfig();
driver = GraphDatabase.driver(uri, AuthTokens.basic(user, password), config);
}
private void addNodes() {
List<Map<String, Object>> listOfProperties = new ArrayList<>();
for (int inner = start; inner < end; inner++) {
Map<String, Object> properties = new HashMap<>();
properties.put("name", "Jhon " + inner);
properties.put("last", "Alan" + inner);
properties.put("id", 2 + inner);
properties.put("key", "1234" + inner);
properties.put("field5", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field6", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field7", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field8", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field9", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field10", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field11", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field12", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field13", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field14", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field15", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field16", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field17", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field18", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field19", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field20", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field21", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field22", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field23", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field24", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field25", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field26", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field27", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field28", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field29", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field30", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field31", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field32", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field33", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field34", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field35", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field36", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field37", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field38", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field39", "kfhc iahf uheguehuguaeghuszjxcb sd");
properties.put("field40", "kfhc iahf uheguehuguaeghuszjxcb sd");
listOfProperties.add(properties);
}
int noOfNodes = 0;
for (int i = 0; i < listOfProperties.size() / 5000; i++) {
List<Map<String, Object>> events = new ArrayList<>();
for (; noOfNodes < (i + 1) * (5000) && noOfNodes < listOfProperties.size(); noOfNodes++) {
events.add(listOfProperties.get(noOfNodes));
}
Map<String, Object> apocParam = new HashMap<>();
apocParam.put("events", events);
String query = "UNWIND $events AS event CREATE (a:Label) SET a += event";
Instant startTime = Instant.now();
try (Session session = driver.session()) {
session.writeTransaction((tx) -> tx.run(query, apocParam));
}
Instant finish = Instant.now();
long timeElapsed = Duration.between(startTime, finish).toMillis();
System.out.println("######################--timeElapsed NODES--############################");
System.out.println("no of nodes per batch " + events.size());
System.out.println(timeElapsed);
System.out.println("############################--NODES--############################");
}
}
public void close() {
driver.close();
}
public static void main(String... args) {
start = 200001;
end = 400001;
if (args.length == 2) {
start = Integer.valueOf(args[0]);
end = Integer.valueOf(args[1]);
}
UnwindCreateNodes unwindCreateNodes = new UnwindCreateNodes("bolt+routing://x.x.x.x:7687", "neo4j", "neo4j");
unwindCreateNodes.addNodes();
unwindCreateNodes.close();
}
}
import org.neo4j.driver.v1.*;
导入java.time.Duration;
导入java.time.Instant;
导入java.util.ArrayList;
导入java.util.HashMap;
导入java.util.List;
导入java.util.Map;
导入java.util.concurrent.TimeUnit;
公共类UnwindCreateNodes{
司机;
静态int启动;
静态输入端;
公共UnwindCreateNodes(字符串uri、字符串用户、字符串密码){
Config=Config.build()
.withConnectionTimeout(10,时间单位。秒)
.toConfig();
driver=GraphDatabase.driver(uri、AuthTokens.basic(用户、密码)、config);
}
私有void addNodes(){
List listOfProperties=new ArrayList();
对于(int-inner=start;innertx.run(query,apocParam));
}
即时完成=即时。立即();
long-timeappeased=Duration.between(startTime,finish).toMillis();
3.系统。输出。系统。输出。打印LN(“(“本方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方#######################;
System.out.println(“每个批处理的节点数”+events.size());
System.out.println(时间流逝);
3.系统。输出。系统。输出。印刷LN(系统。系统。系统。系统。输出。印刷LN(系统)系统。系统。系统。系统。输出。系统。系统。输出。系统。系统。输出。印印政政政治治治治方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方##########################”;
}
}
公众假期结束(){
driver.close();
}
公共静态void main(字符串…参数){
启动=200001;
end=400001;
如果(args.length==2){