How do I build up a Neo4j graph from hundreds of thousands of events? -
we have event sourced application , thinking adding neo4j question view relations. think use case good, problem if replay every event 1 one take time build graph. what's best rebuild graph ~1.000.000 events? resulting graph approx. 100.000 nodes , lot of relations. first naive attempt 1 one takes way time since might want more 1 time.
is best approach build inmemory list of nodes , build large cypher query nodes , 1 relationships? or best way use batch api?
in ideal situation logic rebuilding should same when handle event 1 one live handling "commit" should done after each event.
if requirement keep same logic in application lifecycle events, , use cypher in application, you'll have no choice handle transactional cypher endpoint.
it barely doable, while load csv , batch api give more performance.
i have application write ~1250 cypher statements per cypher transaction, each transaction takes approximately between 0.2 , 0.3 seconds.
some little tips achieve time rate :
do small statements : if need write lot, better eg have 10 small statements match (n1), (n2) merge (n1)-[:follow]->(n2)
big statement 10 merges.
profile queries , make sure indexes correct
stay between 500-1000 statements per transaction.
allow sufficient memory database time of bulk load.
Comments
Post a Comment