66
Ten Reasons Why You Should Use a Graph Database For Your CMS GraphConnect, San Francisco, 6th Nov 2012 Axel Morgner (@amorgner), founder of structr

11:40 Develop: Morgner - Graphdb for CMS

Embed Size (px)

DESCRIPTION

In this talk, I will show how CMS (Content Management Systems) benefit from using a Graph Database as storage layer by highlighting ten illustrative reasons. To support each statements, I will compare different Open Source CMS (including one Graph-CMS) regarding data model, persistence technology, cache layers and strategies, and show some performance numbers and diagrams. And as a historical sidenote, I will talk about Neo4j's CMS roots, enriched with some background information from the founders. Axel Morgner Axel is founder of structr—a free, open-source CMS and Content Management Framework based on the graph database Neo4j. He previously founded inxire GmbH, and was consultant and project manager at Oracle. After leaving the enterprise SQL world behind in 2010, he enjoys now being back to cutting egde technology every day. He’s based in Frankfurt/Main, Germany.

Citation preview

Page 1: 11:40 Develop: Morgner - Graphdb for CMS

Ten Reasons WhyYou Should Use aGraph DatabaseFor Your CMS

GraphConnect, San Francisco, 6th Nov 2012Axel Morgner (@amorgner), founder of structr

Page 2: 11:40 Develop: Morgner - Graphdb for CMS

About me

- 10+ yrs Oracle & ECM- founded inxire (ECM based on Oracle)- left 2010 to start over from scratch- met Peter Neubauer in Frankfurt- started structr

Page 3: 11:40 Develop: Morgner - Graphdb for CMS

About structr- started as CMS/CMF- open sourced 31 May 2011- today: 0.6 about to be released

structr Server structr Ui

Page 4: 11:40 Develop: Morgner - Graphdb for CMS

More info about structr

Website:http://structr.org

Source Code:https://github.com/structr/structr

Forum/Mailing List:https://groups.google.com/forum/#!forum/structr

Twitter:@structr

Page 5: 11:40 Develop: Morgner - Graphdb for CMS

Ten Reasons ...

Page 6: 11:40 Develop: Morgner - Graphdb for CMS

#1Graph Databaseswere made for

Content Management

Page 7: 11:40 Develop: Morgner - Graphdb for CMS

Content Management

Page 8: 11:40 Develop: Morgner - Graphdb for CMS

Content Management

Pages

Sites HTML Elements

Page 9: 11:40 Develop: Morgner - Graphdb for CMS

Content Management

PicturesFiles

Pages

Sites HTML Elements

Texts

Page 10: 11:40 Develop: Morgner - Graphdb for CMS

Content Management

Pictures

Videos

Sounds

Files

Folders

Users

Pages

Sites HTML Elements

Texts

Page 11: 11:40 Develop: Morgner - Graphdb for CMS

Content Management

Pictures

Videos

Sounds

Files

Folders

Categories

Taxonomies

Terms

Users

GroupsRoles

Pages

Sites HTML Elements

Texts

Page 12: 11:40 Develop: Morgner - Graphdb for CMS

Content Management

Pictures

Videos

Sounds

Files

Folders

Categories

Taxonomies

Terms

Users

GroupsRoles

Pages

Sites HTML Elements

Texts

Page 13: 11:40 Develop: Morgner - Graphdb for CMS

Content Management

Pictures

Videos

Sounds

Files

Folders

Categories

Taxonomies

Terms

Users

GroupsRoles

Pages

Sites HTML Elements

Texts

CONTAINS

CONTAINS

CONTAINSACTS_IN

CONTAINS

LINK

LINK

CONTAINS

TAG

TAG

CONTAINS

IS_A

LINK

LINK CONTAINS

Page 14: 11:40 Develop: Morgner - Graphdb for CMS

Neo4j wasinitially made for

Content Management

Page 15: 11:40 Develop: Morgner - Graphdb for CMS

Q: What were the main reasons for you to create Neo4j?

A: We quickly saw that a part of the system was very "networky", and the relational database did not handle many-to-many relationships very well, and not even one-to-many relationships.

We ended up doing joins, and performance was very, very bad. So that's when we started to try different data models than the relational model, and see if we could use that to solve our business problems.

Page 16: 11:40 Develop: Morgner - Graphdb for CMS

Q: All the CMS created at that time, in the early 2000s, were using an O/R mapping layer. So it was quite extra-ordinary that you did not go this way. What gave you the freedom to do that?A: We were young and naïve. :-) And we had a funding at that time, [...] so we decided to try it out. And here we are today.

Q: Permission resolution, was it a particular problem you were faced with?A: Oh yes, well, but we didn't see that at first. The actual problem we used as a starting point was the automatic translation between languages.

Page 17: 11:40 Develop: Morgner - Graphdb for CMS

#1Graph Databases1

were made forContent Management2

1 at least Neo4j2 not exclusively

Page 18: 11:40 Develop: Morgner - Graphdb for CMS

#2O/R Mapping

Page 19: 11:40 Develop: Morgner - Graphdb for CMS

Core Data

Page 20: 11:40 Develop: Morgner - Graphdb for CMS

Core Data

Page 21: 11:40 Develop: Morgner - Graphdb for CMS

#2No O/R Mapping

=Less Code

Less Runtime ObjectsLess Complexity

Page 22: 11:40 Develop: Morgner - Graphdb for CMS

#3Visualization

Page 23: 11:40 Develop: Morgner - Graphdb for CMS

#3Graph Visualization

=Understand how your

data is connected

Page 24: 11:40 Develop: Morgner - Graphdb for CMS

#4Schema

Page 25: 11:40 Develop: Morgner - Graphdb for CMS

Content Graph

Pictures

Videos

Sounds

Files

Folders

Categories

Taxonomies

Terms

Users

GroupsRoles

Pages

Sites HTML Elements

Texts

CONTAINS

CONTAINS

CONTAINSACTS_IN

CONTAINS

LINK

LINK

CONTAINS

TAG

TAG

CONTAINS

IS_A

LINK

LINK CONTAINS

Page 26: 11:40 Develop: Morgner - Graphdb for CMS

Domains as Sub Graphs

Pictures

Videos

Sounds

Files

Folders

Categories

Taxonomies

Terms

Users

GroupsRoles

Pages

Sites HTML Elements

Texts

CONTAINS

CONTAINS

CONTAINSACTS_IN

CONTAINS

LINK

LINK

CONTAINS

TAG

TAG

CONTAINS

IS_A

LINK

LINK CONTAINS

Page 27: 11:40 Develop: Morgner - Graphdb for CMS

#4No Fixed Schema

=Flexibility

Late Optimization

Page 28: 11:40 Develop: Morgner - Graphdb for CMS

#5Templates

Page 29: 11:40 Develop: Morgner - Graphdb for CMS

Page Rendering<html>

<head>

<meta http-equiv="Content-Type"

content="text/html; charset=utf-8"/>

<title>${content.title!}</title>

</head>

<body>

<h1>${content.title!}</h1>

</body>

Page Template

Database

Data Objects

Page 30: 11:40 Develop: Morgner - Graphdb for CMS

Page Rendering<html>

<head>

<meta http-equiv="Content-Type"

content="text/html; charset=utf-8"/>

<title>${content.title!}</title>

</head>

<body>

<h1>${content.title!}</h1>

</body>

Page Template

Database

Data Objects O/R Layer

Page 31: 11:40 Develop: Morgner - Graphdb for CMS

Page Rendering<html>

<head>

<meta http-equiv="Content-Type"

content="text/html; charset=utf-8"/>

<title>${content.title!}</title>

</head>

<body>

<h1>${content.title!}</h1>

</body>

Page Template

Database

Data ObjectsTemplateEngine O/R Layer

Page 32: 11:40 Develop: Morgner - Graphdb for CMS

Page Rendering<html>

<head>

<meta http-equiv="Content-Type"

content="text/html; charset=utf-8"/>

<title>${content.title!}</title>

</head>

<body>

<h1>${content.title!}</h1>

</body>

Page Template

Database

Data Objects O/R LayerTemplateEngine

WebServer

Page 33: 11:40 Develop: Morgner - Graphdb for CMS

Page Rendering<html>

<head>

<meta http-equiv="Content-Type"

content="text/html; charset=utf-8"/>

<title>${content.title!}</title>

</head>

<body>

<h1>${content.title!}</h1>

</body>

Page Template

Database

Data Objects O/R LayerTemplateEngine

WebServer

Page 34: 11:40 Develop: Morgner - Graphdb for CMS

Page Rendering<html>

<head>

<meta http-equiv="Content-Type"

content="text/html; charset=utf-8"/>

<title>${content.title!}</title>

</head>

<body>

<h1>${content.title!}</h1>

</body>

Page Template

Database

Data Objects O/R LayerTemplateEngine

WebServer

Page 35: 11:40 Develop: Morgner - Graphdb for CMS

Page Rendering<html>

<head>

<meta http-equiv="Content-Type"

content="text/html; charset=utf-8"/>

<title>${content.title!}</title>

</head>

<body>

<h1>${content.title!}</h1>

</body>

Page Template

Database

Data Objects O/R LayerTemplateEngine

WebServer

Page 36: 11:40 Develop: Morgner - Graphdb for CMS

Page Rendering<html>

<head>

<meta http-equiv="Content-Type"

content="text/html; charset=utf-8"/>

<title>${content.title!}</title>

</head>

<body>

<h1>${content.title!}</h1>

</body>

Page Template

Database

Data Objects O/R LayerTemplateEngine

WebServer

Page 37: 11:40 Develop: Morgner - Graphdb for CMS

Page Rendering

RenderingEngine

WebServer

Page 38: 11:40 Develop: Morgner - Graphdb for CMS

Page Rendering

Database:Content Graph

Data Objects:Content Graph

RenderingEngine

WebServer

Page 39: 11:40 Develop: Morgner - Graphdb for CMS

#5No (classic) Templates

=Reduced Complexity

Less Caching

Page 40: 11:40 Develop: Morgner - Graphdb for CMS

#6Caching

Page 41: 11:40 Develop: Morgner - Graphdb for CMS

Caching Benchmark

0

12,5

25

37,5

50

req/s (w/o caching) 0

46

109

Wordpress 3.4.2 Drupal 7.16 structr 0.6 Apache

0

1000

2000

3000

4000

req/s (w/ caching)

3500

13191244

320

Page 42: 11:40 Develop: Morgner - Graphdb for CMS

#6Less Caching

=Less Cache Sync./Invalid.

Less Cache Objects

Page 43: 11:40 Develop: Morgner - Graphdb for CMS

#7Permission Resolution

Page 45: 11:40 Develop: Morgner - Graphdb for CMS

ACLs

Page 46: 11:40 Develop: Morgner - Graphdb for CMS

ACLs

Page 47: 11:40 Develop: Morgner - Graphdb for CMS

ACLs

Page 48: 11:40 Develop: Morgner - Graphdb for CMS

ACLs

Page 49: 11:40 Develop: Morgner - Graphdb for CMS

#7Real-time ACL

Resolution=

Fast Access toProtected Content

Page 50: 11:40 Develop: Morgner - Graphdb for CMS

#8Memory Footprint

Page 51: 11:40 Develop: Morgner - Graphdb for CMS

#9Dependencies

Page 52: 11:40 Develop: Morgner - Graphdb for CMS

#10Complex Features

Page 53: 11:40 Develop: Morgner - Graphdb for CMS

Example: Versioning

Folder A

Document X

CONTAINS

Folder B

Document X

CONTAINS

t0 t1

Page 54: 11:40 Develop: Morgner - Graphdb for CMS

Example: Versioning

Folder A

CONTAINS

Document X

Page 55: 11:40 Develop: Morgner - Graphdb for CMS

Example: Versioning

Folder B

Document X

CONTAINS

Page 56: 11:40 Develop: Morgner - Graphdb for CMS

Example: Versioning

Folder A

CONTAINS

Folder B

Document X

CONTAINS

valid_until: t1 valid_from: t1

Page 57: 11:40 Develop: Morgner - Graphdb for CMS

Example: Versioning

Folder A

CONTAINS

Folder B

Document X

CONTAINS

valid_until: t1 valid_from: t1

User 1

SECURITYread: true

write: falsevalid_from: t2

SECURITYread: truewrite: true

valid_until: t2

Page 58: 11:40 Develop: Morgner - Graphdb for CMS

Example: Versioning

Folder A

CONTAINS

Folder B

Document X

User 1

SECURITYread: truewrite: true

valid_until: t2

t0

Page 59: 11:40 Develop: Morgner - Graphdb for CMS

Example: Versioning

Folder A Folder B

Document X

CONTAINS

User 1

SECURITYread: truewrite: true

t1

Page 60: 11:40 Develop: Morgner - Graphdb for CMS

Example: Versioning

Folder A Folder B

Document X

CONTAINS

User 1

SECURITYread: true

write: false

t2

Page 61: 11:40 Develop: Morgner - Graphdb for CMS

Conclusions

Page 62: 11:40 Develop: Morgner - Graphdb for CMS

ConclusionsNo O/R mappingLess cachingEasy visualization

Simplicity

Page 63: 11:40 Develop: Morgner - Graphdb for CMS

ConclusionsNo O/R mappingLess cachingEasy visualization

Real-time ACL resolutionSmaller memory footprintLess dependencies

Simplicity

Performance

Page 64: 11:40 Develop: Morgner - Graphdb for CMS

ConclusionsNo O/R mappingLess cachingEasy visualization

Real-time ACL resolutionSmaller memory footprintLess dependencies

Complex features are easierNo (classic) templatesNo fixed schema

Simplicity

Performance

Flexibility

Page 65: 11:40 Develop: Morgner - Graphdb for CMS

Graph Databaseswere made for

Content Management

Page 66: 11:40 Develop: Morgner - Graphdb for CMS

Thank you!