In Memory Graph Database?

MemGraph vs RedisGraph

TheSource51
3 min readApr 20, 2023
Example graph

Memgraph and RedisGraph are both graph databases that store data in memory for fast performance. However, they have some differences in their features, design and use cases.

Memgraph logo

Memgraph is a standalone graph database that is compatible with Neo4j, the leading graph platform. It supports streaming data ingestion, distributed processing and real-time analytics. It also uses Cypher as its query language, but with some extensions and optimizations. Memgraph is available as both open source (BSL) and commercial versions, and can be deployed on-premises or on the cloud.

Getting started:

docker run -it -p 7687:7687 -p 7444:7444 -p 3000:3000 memgraph/memgraph-platform
// Import the neo4j-driver module
var neo4j = require("neo4j-driver");

// Create a new driver object
const driver = neo4j.driver("bolt://localhost:7687");

// Create a new session object
const session = driver.session();

// Create some nodes and relationships
session
.writeTransaction((tx) =>
tx.run(
"CREATE (:person {name:'Alice', age:32}), (:person {name:'Bob', age:30}), (:person {name:'Charlie', age:28}), (a:person)-[:knows]->(b:person), (a:person)-[:knows]->(c:person)"
)
)
.then(() => {
// Query the graph data
return session.readTransaction((tx) =>
tx.run("MATCH (a:person)-[:knows]->(b:person) RETURN a.name, b.name")
);
})
.then((result) => {
// Print the results
result.records.forEach((record) => {
console.log(record.get("a.name") + " knows " + record.get("b.name"));
});
})
.catch((error) => {
// Handle errors
console.error(error);
})
.finally(() => {
// Close the session and driver
session.close();
driver.close();
});
RedisGraph logo

RedisGraph on the other hand, is a module that extends Redis, a popular key-value store, with graph capabilities. It’s based on GraphBlas and also supports Cypher to index and query graph data. It also supports data persistence, based on Redis persistence solution. As Memgraph, it is available as both open source (SSPLv1) and commercial versions, and can be deployed on-premises or on the cloud.

Getting started:

docker run -p 6379:6379 -it --rm redis/redis-stack-server
// Import the node-redis module
import { createClient, Graph } from 'redis';

// Create a new client object
const client = createClient();
client.on('error', (err) => console.log('Redis Client Error', err));

// Connect to the database
await client.connect();

const graph = new Graph(client, 'social');

// Create some nodes and relationships
await graph.query(
"CREATE (:person {name:'Alice', age:32}), (:person {name:'Bob', age:30}), (:person {name:'Charlie', age:28}), (a:person)-[:knows]->(b:person), (a:person)-[:knows]->(c:person)"
);

// Query the graph data
const result = await graph.roQuery("MATCH (a:person)-[:knows]->(b:person) RETURN a.name, b.name");

// Print the results
console.log(result.data);

Some possible use cases for Memgraph are:

- Processing streaming data from IoT devices or sensors
- Building fraud detection or cybersecurity applications
- Performing graph analytics on large-scale datasets

Some possible use cases for RedisGraph are:

- Caching graph data for fast access
- Building recommendation systems or social networks
- Performing graph analytics on small to medium-sized datasets

Both Memgraph and RedisGraph are low latency powerful tools for working with graph data, but they have different strengths and trade-offs.

--

--