Dgraph is a high-scalable, low-latency, and high-throughput distributed graph database. It emphasizes concurrency in distributed environment by minimizing network calls. Built on the idea that everyone deserves an internet-scale graph database, the native GraphQL database-as-a-service with Dgraph Cloud lets anyone access the world's most advanced graph database.[03][04][05]
- Website
- https://docs.dgraph.io[01]
- Source Code
- https://github.com/dgraph-io/dgraph[02]
- Developer
- Country of Origin
- US
- Project Types
- Commercial, Open Source
- Written in
- Go
- Supported Languages
- Go
- Derived From
- BadgerDB
- License
- Apache v2
Dgraph is a high-scalable, low-latency, and high-throughput distributed graph database. It emphasizes concurrency in distributed environment by minimizing network calls. Built on the idea that everyone deserves an internet-scale graph database, the native GraphQL database-as-a-service with Dgraph Cloud lets anyone access the world's most advanced graph database.[03][04][05]
History[06][07][08][09][10]
In July 2015, Manish Rai Jain created Dgraph based on his previous experience at Google -- there he led a project to unite all data structures for serving web search with a backend graph system. The first version v0.1 was released in December 2015, with the goal offering an open source, native, and distributed graph database never changes since then. In 2020, Dgraph launched hosted Dgraph with Dgraph Cloud. The only native GraphQL graph database available on AWS, GCP, and Azure, Dgraph Cloud has three tiers. The free tier lets users get started and try out the service. The shared and dedicated tiers are ideal for app developers or companies. Thanks to the scalability of Dgraph, enterprises are using it with terabytes of data in production.
Checkpoints[11]
The checkpoint scheme is not mentioned in Dgraph documentation. Therefore, questions are raised in Dgraph slack group. The above answer was provided by developers directly, but details were not revealed.
Concurrency Control[12][13]
Dgraph's main focus is low latency and high throughput. It references the design of Google's Bigtable and Facebook's Tao, and achieves high scalability at the cost of lack of full ACID compliant transactional support. Also, value data versioning is under consideration, and not yet implemented
Data Model[14]
In Dgraph, a PostingList contains all DirectedEdge corresponding to an Attribute, where each DirectedEdge consists of entity, attribute, value, etc. Note that posting lists are all served via RocksDB in a key-value format (Predicate, Subject) --> PostingList.
Foreign Keys[15]
In contrast to foreign key in relational database, nodes in graph database don't possess properties. Foreign relationships are represented by edges and should not exist implicitly. In Dgraph, creating relationships on top of data is the only way to model the data.
Indexes[14][16][17]
Dgraph relies on RocksDB to serve PostingLists and provide indexing. Here RocksDB uses key-value format to make radom lookups efficient, and supports faster hash-based index in plain table compared with block-based table.
Isolation Levels[18]
Dgraph does not support transactions at this point. A mutation can be composed of multiple edges where each edge might belong to a different PostingList. Dgraph acquires RWMutex locks at a posting list level. It does not acquire locks across multiple posting lists. For writes, some edges would get written before others, and so any reads which happen while a mutation is going on would read partially committed data. However, there's a guarantee of durability. When a mutation succeeds, any successive reads will read the updated data in its entirety.
Joins[19][20]
Dgraph's PostingList structure stores all DirectedEdges corresponding to an Attribute in the format of Attribute: Entity -> sorted list of ValueId, which already consists of all data needed for a join. Therefore, each RPC call to the cluster would result in only one join rather than multiple joins. Join operation is reduced to lookup rather than application layer.
Logging[21]
Dgraph's logging scheme is close to logical logging. Every mutation is logged and then synced to disk via append-only log. Additionally, two layers of mutation responsible for replacing and addition/deletion respectively can log mutations in memory, allowing periodical garbage collection for dirty posting list via RocksDB. This reduces the need for recreating the posting lists.
Query Compilation
No information about query compilation related knowledge is found in Dgraph wiki or discussion.
Query Interface[23][24]
Dgraph uses a variation of GraphQL (created by Facebook) called GraphQL+- as its query language because of GraphQL's graph-like query syntax, schema validation and subgraph shaped response. The difference is that GraphQL+- supports graph operations and has removed some inappropriate features considering graph database's special structure.
Storage Architecture[25]
RocksDB library would decide how data are served out of memory, SSD or disk. In order to proceed processing, updates to posting lists can be stored in memory as an overlay over immutable Posting list. Two separate update layers are provided for replacing and addition/deletion respectively, which allows iteration over Postings in memory without fetching things from disk.
Storage Model[26]
Dgraph utilizes RocksDB (an application library rather than a database) to help with key-value storage of posting lists on disk. However, all data handling still happens at Dgraph level rather than RocksDB. RocksDB functions as an interface of disk for Dgraph.
Stored Procedures[27]
Functions can only be applied to indexed attributes. Some pre-defined functions like term matching, inequality and geolocation are provided. Users only need to fill in the parameters to do customized procedures.
System Architecture[28]
Dgraph uses RAFT consensus algorithm for communication between servers. During each term (election cycle), voting is conducted to decide a single leader. Then there is unidirectional RPC communication from leader to followers, but they don't share disk naturally. Each server exposes a GRPC interface, which can then be called by the query processor to retrieve data. Clients must locate the cluster to interact with it. A client can randomly pick up any server in the cluster. If not picking a leader, the request should be rejected, and the leader information is passed along. The client can then re-route it's query to the leader.
Citations
28 sources- Dgraph Documentation dgraph.io
- GitHub - dgraph-io/dgraph: high-performance graph database for real-time use cases · GitHub github.com
- https://wiki.dgraph.io/Frequently_asked_questions#Why_build_Dgraph.3F dgraph.io
- https://wiki.dgraph.io/Frequently_asked_questions#Is_Dgraph_fast.3F dgraph.io
- Jepsen: Dgraph 1.1.1 jepsen.io
- Dgraph raises $3M for its open-source distributed graph database, hits 1.0 release | TechCrunch techcrunch.com
- Big Data Archives | TechRepublic techrepublic.com
- https://wiki.dgraph.io/Dgraph#History dgraph.io
- Dgraph GraphQL database users detail graph use cases | TechTarget techtarget.com
- After two failed startups, ex-Google employee secures $1.45 million in funding and the backing of the co-founder of Atlassian - SmartCompany smartcompany.com.au
- Slack slack.com
- https://wiki.dgraph.io/Dgraph_compared_to_other_databases dgraph.io
- https://wiki.dgraph.io/Design_concepts#Versioning dgraph.io
- https://wiki.dgraph.io/Design_concepts#RocksDB dgraph.io
- dgraph/wiki/content/guides/intro-to-graphs.md at a85a5b9494863af28daf73f8ccb3fd848907811e · dgraph-io/dgraph · GitHub github.com
- dgraph/vendor/github.com/cockroachdb/c-rocksdb/internal/table/plain_table_index.cc at 3269e3df2582ad06901230c50b38d8745d1d4f73 · dgraph-io/dgraph · GitHub github.com
- A Tutorial of RocksDB SST formats · facebook/rocksdb Wiki · GitHub github.com
- https://wiki.dgraph.io/Dgraph#Note_on_Transactions dgraph.io
- https://docs.dgraph.io/v0.7.4/design-concepts dgraph.io
- https://docs.dgraph.io/v0.7.4/faq dgraph.io
- https://wiki.dgraph.io/Design_concepts#Commit_Logs dgraph.io
- https://wiki.dgraph.io/Design_concepts#Queries dgraph.io
- https://docs.dgraph.io/v0.7.6/query-language dgraph.io
- https://facebook.github.io/graphql github.io
- https://wiki.dgraph.io/Design_concepts dgraph.io
- https://wiki.dgraph.io/Frequently_asked_questions dgraph.io
- https://wiki.dgraph.io/Query_Language#Functions dgraph.io
- https://wiki.dgraph.io/Design_concepts#RAFT dgraph.io