Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Dgraph: Graph database for production environment

Dgraph: Graph database for production environment

Talk given at Gophercon India about Dgraph: https://dgraph.io.

Manish R Jain

February 24, 2017
Tweet

More Decks by Manish R Jain

Other Decks in Programming

Transcript

  1. When should you use a graph database? Relational database with

    more than 5 foreign ids, better handled by graph databases. Ideal for newsfeeds, recommendation engines, context based search, pattern and fraud detection, and more.
  2. What is Dgraph? Dgraph is an open source graph database

    built for web-scale production environments written entirely in Go. Sharded and Distributed (Distributed Joins, Filters and Sorts) Horizontally scalable. Automatic Replication Consistency (CP in CAP) via Raft Highly Available by design Fault tolerant
  3. Why build it? Any company doing anything smart is using

    graphs. No native scalable solution.
  4. Neo4j query Dgraph is 3x-6x faster on a read-write workload.

    At least as fast on read-only. Link to full benchmark code (https://github.com/dgraph-io/benchmarks/tree/master/data/neo4j)
  5. Cayley (with Bolt on Macbook) Cayley is a graph layer

    written in Go. Loading 21M RDFs Dgraph is 9.7x faster Queries (Gremlin) Dgraph is 36.6x faster Queries (MQL) Draph is 5x faster Link to full benchmark code (https://github.com/ankurayadav/graphdb-benchmarks)
  6. Atomic Consistency (aka Linearizability) Reads after a successful write are

    guaranteed to return that (or future) write irrespective of which replica is queried.
  7. Life of a Query Aka how we solve the problem

    of distributed joins, distributed lters and distributed sorts e ciently.
  8. Life of a Query { # Find movies by Steven

    Spielberg named 'Indiana', sorted in desc order. steven(id: m.06pj8) { director.film @filter(anyof(name.en, "indiana")) (orderdesc: initial_release_date) { name.en initial_release_date } } }
  9. Life of a Query: Expand Out { # Find movies

    by Steven Spielberg named 'Indiana', sorted in desc order. steven(id: m.06pj8) { director.film @filter(anyof(name.en, "indiana")) (orderdesc: initial_release_date) { name.en initial_release_date } } }
  10. Life of a Query: Apply Filters { # Find movies

    by Steven Spielberg named 'Indiana', sorted in desc order. steven(id: m.06pj8) { director.film @filter(anyof(name.en, "indiana")) (orderdesc: initial_release_date) { name.en initial_release_date } } }
  11. Life of a Query: Sort and Paginate { # Find

    movies by Steven Spielberg named 'Indiana', sorted in desc order. steven(id: m.06pj8) { director.film @filter(anyof(name.en, "indiana")) (orderdesc: initial_release_date) { name.en initial_release_date } } }
  12. Life of a Query: Process Children { # Find movies

    by Steven Spielberg named 'Indiana', sorted in desc order. steven(id: m.06pj8) { director.film @filter(anyof(name.en, "indiana")) (orderdesc: initial_release_date) { name.en initial_release_date } } }
  13. Life of a Query: ToJSON { "steven": [ { "director.film":

    [ { "initial_release_date": "2008-05-18", "name.en": "Indiana Jones and the Kingdom of the Crystal Skull" }, { "initial_release_date": "1989-05-24", "name.en": "Indiana Jones and the Last Crusade" }, { "initial_release_date": "1984-05-23", "name.en": "Indiana Jones and the Temple of Doom" }, { "initial_release_date": "1981-06-12", "name.en": "Indiana Jones and the Raiders of the Lost Ark" } ] } ] }
  14. Things we like about Go Simplicity of code Concurrency: Goroutines

    and Channels Pro ling via pprof Benchmarks RPC tracing via contexts Advanced memory management using sync.Pool or Slice tricks. Gofmt Compiler
  15. Things pushing us away from Go Having to use Cgo,

    due to lack of good library support. CJK tokenizer, equivalent of ICU Well designed key-value store
  16. Removing Cgo from Dgraph entirely T raffic is driving me

    nuts. Am going to build a tunnel boring machine and just start digging... 12:05 AM - 18 Dec 2016 13,580 42,245 Elon Musk @elonmusk Follow Fed up with Cgo! Planning to write an LSM based KV store from scratch in #golang based on WiscKey paper and RocksDB. Got any advice? Ping me 11:39 AM - 26 Jan 2017 1 Manish Rai Jain @manishrjain Follow
  17. 5. Demo Try it out: curl https://get.dgraph.io -sSf | bash

    Get Started with Dgraph (https://wiki.dgraph.io/Get_Started)
  18. 6. Q & A Got questions? Find me and Dgraph

    team on breaks, or Knock at our doors. We're staying at Hyatt.