This is a little long answer, please bear with me. Let me first explain what is RocksDB and graph database, then go over how do I solve this problem.
RocksDB is an embedded key-value persistent store. It is highly optimized for SSDs/flash
drives. RocksDB uses a log structured database engine, entirely in C++ for maximum
performance. We can tune the RocksDB options based on the application's need to get better performance. More on this http://rocksdb.org/.
A graph database is a database that uses graph structures for semantic queries with nodes,
edges and properties to represent and store data. The underlying storage mechanism for
graph database varies. Some depend on a relation engine other depend on key-value store or document oriented database. More on this https://en.wikipedia.org/wiki/Graph_database.
For social apps, in general, graph databases can be used rather than relational databases.
In theory, graph databases give better performance for level deep queries. When we
implement graph database, the storage layer can be implemented using RocksDB.
If I were to implement a small social app which supports creation of posts, send/receive
comments and likes, this is how I would solve this problem.
We can represent each person in the app as node and they can be linked with other users or topic by different relationships. Each relationship as an edge. Inside the storage layer, each node is a key-value entry and as well each edge also a key-value entry. As we process the node in the graph and navigate through the edge, each will be a lookup inside the storage layer. RocksDB's lookups are very fast. In order to get better performance, we can maintain two RocksDB instances; one for the nodes and other one for the edges.
The pictorial representation of the graph would be .
Why would I prefer RocksDB ?
provides very efficient lookup
most of the stuff are from in-memory (can be configured depending memory requirements)
This is a little long answer, please bear with me. Let me first explain what is RocksDB and graph database, then go over how do I solve this problem.
RocksDB is an embedded key-value persistent store. It is highly optimized for SSDs/flash drives. RocksDB uses a log structured database engine, entirely in C++ for maximum performance. We can tune the RocksDB options based on the application's need to get better performance. More on this http://rocksdb.org/.
A graph database is a database that uses graph structures for semantic queries with nodes, edges and properties to represent and store data. The underlying storage mechanism for graph database varies. Some depend on a relation engine other depend on key-value store or document oriented database. More on this https://en.wikipedia.org/wiki/Graph_database.
For social apps, in general, graph databases can be used rather than relational databases. In theory, graph databases give better performance for level deep queries. When we implement graph database, the storage layer can be implemented using RocksDB.
If I were to implement a small social app which supports creation of posts, send/receive comments and likes, this is how I would solve this problem.
We can represent each person in the app as node and they can be linked with other users or topic by different relationships. Each relationship as an edge. Inside the storage layer, each node is a key-value entry and as well each edge also a key-value entry. As we process the node in the graph and navigate through the edge, each will be a lookup inside the storage layer. RocksDB's lookups are very fast. In order to get better performance, we can maintain two RocksDB instances; one for the nodes and other one for the edges.
The pictorial representation of the graph would be
.
Why would I prefer RocksDB ?