betting the company on a graph database - aseem kishore @ graphconnect boston 2013

41
BETTING THE COMPANY BETTING THE COMPANY (LITERALLY) ON A GRAPH DATABASE GRAPH DATABASE TIPS, TRICKS, AND LESSONS LEARNED Aseem Kishore Jan 2013

Upload: neo4j-the-open-source-graph-database

Post on 27-Jan-2015

110 views

Category:

Technology


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013

BETTING THE COMPANYBETTING THE COMPANY

(LITERALLY) ON A

GRAPH DATABASEGRAPH DATABASE

TIPS, TRICKS, AND LESSONS LEARNED

Aseem KishoreJan 2013

Page 5: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013
Page 7: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013
Page 8: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013
Page 9: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013

START user=node(1), other=node(2)MATCH (user) -[r1:has|wants]-> (thing) <-[r2:has|wants]- (other)WHERE TYPE(r1) <> TYPE(r2)RETURN TYPE(r1), TYPE(r2), thing

Page 10: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013
Page 11: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013

Daniel Gasienica@gasi

Page 12: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013

SO…

JUST WHAT IS A

GRAPH DATABASEGRAPH DATABASE?

Page 13: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013
Page 14: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013

# adjacency list:nodes = List<Node>neighbors = Map<Node, List<Node>>neighbors[node1].add(node2)

# adjacency matrix:nodes = List<Node>connections = Map<Node, Map<Node, bool>>connections[node1][node2] = true

Page 15: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013
Page 16: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013
Page 17: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013
Page 18: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013

“ By definition, a graph database is any storagesystem that provides index-free adjacency. ”

“ This means that every element contains adirect pointer to its adjacent element and noindex lookups are necessary. ”

Page 19: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013

QUERYING

1. Start somewhere

2. Traverse elsewhere

Page 20: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013

QUERYING IN NEO4J

1. Start somewhereRoot nodeID directly (file offset)

Lucene index

2. Traverse elsewhere

Traversal APIsCypher patternsBuilt-in graph algos (Djikstra, A*, etc.)

Page 21: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013

NEO4J USAGE

Embedded mode (Java API)

Server mode (REST API)

Cypher query language (both)

Page 22: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013

OUR USAGE

NODE.JS

+

REST API

+

CYPHER

Page 24: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013

NEO4J EDITIONS

Community editionSingle instanceOffline backup

Advanced editionMeh

Enterprise editionMulti-instance cluster!

Online backup!

Page 25: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013

NEO4J SCALING

Master-slave replication

Cache-based sharding

Feature-based polyglot'ing

64B limit on nodes, rels, propsBut can be easily upped; just flipping some bits100 props/node (high) ⇒ 640M nodes

Page 26: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013

OKAY...

LET'S TALK ABOUT

WHAT WE LEARNEDWHAT WE LEARNED

Page 27: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013
Page 28: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013

WHAT WE LEARNED

Unique, expressive relationship types

Page 29: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013
Page 30: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013

WHAT WE LEARNED

Unique, expressive relationship types

Cache stats where possible

Page 31: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013
Page 32: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013

WHAT WE LEARNED

Unique, expressive relationship types

Cache stats where possible

Capture history through event nodes

Page 33: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013
Page 34: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013

WHAT WE LEARNED

Unique, expressive relationship types

Cache stats where possible

Capture history through event nodes

First-class objects ⇒ nodes, not rels

Page 35: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013
Page 36: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013

WHAT WE LEARNED

Unique, expressive relationship types

Cache stats where possible

First-class objects ⇒ nodes, not rels

Capture history through event nodes

Connected data ⇒ nodes, not props

Page 37: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013
Page 38: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013

WHAT WE LEARNED

Unique, expressive relationship types

Cache stats where possible

First-class objects ⇒ nodes, not rels

Capture history through event nodes

Connected data ⇒ nodes, not props

Maintain linked lists for O(1) queries

Page 39: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013

NEO4J ROADMAP

Overhaul of indexing API

Relationship type grouping

Socket and/or binary protocol

Automatic sharding?

Page 41: Betting the Company on a Graph Database - Aseem Kishore @ GraphConnect Boston 2013

THANKS!

TWITTER: @ASEEMK

GITHUB: @ASEEMK

EMAIL: [email protected]

Questions?