Star

Performance Comparison: Neo4j vs Nebula Graph vs JanusGraph

Who Did the Comparison

This article describes how the Tencent (HKG.0700) Cloud team compares Nebula Graph with two other popular graph databases on the market from several perspectives.

By their nature of dealing with interconnections, graph databases are perfect for fraud detection and building knowledge graphs in the security field. To better serve the Tencent Cloud business scenarios, the Tencent Cloud Security team has to select a highly performant graph database which fits the business development well, which is how this performance comparison comes into play.

Whom to Compare With

Neo4j

Neo4j is the most widely adopted graph database in the industrial world. It has a Community edition and an Enterprise edition. For comparison in this article, the team has chosen the Community edition.

HugeGraph (A fork of JanusGraph)

HugeGraph is a distributed graph database developed by Baidu (NASDAQ: BIDU). It is forked from JanusGraph. HugeGraph is developed to address the needs of anti-fraud, threat intelligence collection, and underground economy attack with graph storage and analysis capabilities. It has pretty good read and write performance.

Nebula Graph

Nebula Graph is an open source distributed graph database developed by vesoft inc. It features the capability of dealing with super large datasets with hundreds of billions of vertices and trillions of edges.

Hardware Environments

Item Specs
CPU Intel Xeon® Gold 6133 CPU @ 2.5GHz X86_64
# of Physical CPUs 2
# of Physical Cores 20
# of Logical CPUs 80
Memory 260 GB

Test Results

The Tencent Cloud Security team has used graph data at different orders of magnitudes for testing purpose. The test has been performed against various metrics, including data import efficiency, one-hop query, two-hop query, and shared friends query.

The results are as below:

Graph Data Size Platform Data Import One-Hop Query Two-Hop Query Shared Friends Query
10 Million Edges Neo4j 26s 6.618s 6.644s 6.661s
HugeGraph 89s 16ms 22ms 72ms
Nebula Graph 32.63s 1.482ms 3.095ms 0.994ms
100 Million Edges Neo4j 1min21s 42.921s 43.332s 44.072s
HugeGraph 10min 19ms 20ms 5s
Nebula Graph 3min52s 1.971ms 4.34ms 4.147ms
1 Billion Edges Neo4j 8min34s 165.397s 176.272s 168.256s
HugeGraph 65min 19ms 651ms 3.8s
Nebula Graph 29min35s 2.035s 22.48ms 1.761ms
8 Billion Edges Neo4j 1h23min 314.34s 393.18s 608.27s
HugeGraph 16h 68ms 24s 541ms
Nebula Graph ~30min Less than 1s Less than 5s Less than 1s

Seen from the above table, in terms of data import, Nebula Graph is a bit slower than Neo4j when the data size is small. However, when the data size is large, Nebula Graph is much faster than the other two. For the three graph queries, Nebula Graph shows clearly better performance compared to Neo4j and HugeGraph.

Here is a chart overview for the comparison:

Graph Query Language Comparison

Platform / Query Language One-Hop Friends Query Two-Hop Friends Query Shared Friends Query
Neo4j / Cyher match ( {vid:11111}
) -> (u)
return u;
match ( {vid:11111}
) -> () -> u
return u;
match ( {vid:11111}
) -> (u) <- ({vid:22222})
return u;
HugeGraph / gremlin g.V ().has (‘vid’, ‘attr’, ‘11111’). both E ().otherV ().dedup ().count () g.V ().has (‘vid’, ‘attr’, ‘11111’). both E ().otherV ().dedup ().both E ().otherV ().count () g.V ().has (‘vid’, ‘attr’, ‘11111’). both E ().otherV ().aggregate(‘x’).has(‘vid’, ‘attr’, ‘22222’).bothE().otherV().where(within(‘x’)).dedup().count()
Nebula Graph / nGQL GO FROM 11111 OVER relation GO 2 STEPS FROM 11111 OVER relation GO FROM 11111 OVER relation
INTERSECT
GO FROM 22222 OVER relation

From the graph query language point of view, gremlin is complex and nGQL and Cypher are simple and neat. From the readability point of view, nGQL is similar to SQL and the learning curve should be shorter.

Graph Visualization Comparison

Platform Layout Support Smoothness Exploration from a Selected Node Query in Batch Node Style Customization
Neo4j Yes Smooth for one-hop query No Yes Yes
HugeGraph No Smooth for one-hop query No No Yes
Nebula Graph Yes Smooth for one-hop query Yes Yes No

In terms of graph visualization, it is safe to say that all the mentioned platforms are just available for use. Nebula Graph supports exploration from a selected node, which is a plus. However, there is still room for improvement for the smoothness of two-hop friends query results layout and node style customization.

After comparing multiple widely adopted open source graph databases and taking into consideration of factors such as performance, learning curve, and fitness to the business scenarios, the Tencent Cloud Security team has finally selected Nebula Graph, a highly performant and easy-to-use graph database.

This article is written by Li Hangyu and Deng Changbo from the Tencent Cloud Security team.

1 Like

Hi,

Thanks for sharing the work.

I think the comparison is not accurate or omplete. In the queries used above, Cypher of Neo4j returned neighbour nodes, however the HugeGraph query only returned a count, and Nebula one didn’t return anything. For a fair compariosn, you should write Cypher like this:

match ( {vid:11111}) --> (u)
return count(u);

A better way is to add Label to node:
match ( n:Person {vid:11111}) --> (u)
return count(u);

The correct way is to define Index on vid property of Person node and run query. This should return in just ms.

If the team made the product selection simply based on what’s described in the article, I’d say it’s not complete and misleading.

Cheers

Indeed HugeGraph query return count in example. However, Nebula will return dstId of an edge if no property specified by default, so Nebula is same with Neo4j in this case. I agree that it would be misleading.

感觉3种图耗时对比有问题吧,还是语句没有写全。One-Hop Friends Query 和 Two-Hop Friends Query ,HugeGraph 直接用both() 就可以吧,而且返回的是去重后的总数,而其他2种图是返回的顶点吧,而且 Nebula over relation 是确定的边,还是 * ,而且这里不是双向跳跃吧,希望能更加完善一些吧。 现在nebula的文档是真的少,但国内好多大厂推荐,一时不知道改不改,现在用的是janusgraph

@COBSNAN 可以来我们的中文论坛进行交流呀,两边的性能报告内容都是相同的,你可以直接和作者用中文交流,btw 可以阅读下 360 研发团队写的 https://discuss.nebula-graph.com.cn/t/topic/1172/5

以及这篇文章的中文版,由腾讯云团队编写的:https://discuss.nebula-graph.com.cn/t/topic/1013

好的 谢谢