44
NoSQL Using the right tool for the right job

Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

Embed Size (px)

Citation preview

Page 1: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

NoSQLUsing the right tool for the right job

Page 2: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 2

No SQL

Page 3: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 3

No SQL

Not Only/ I /I

Page 4: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 4

No SQL

Not Only/ I /I/

/

Page 5: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 5

No SQL

Not Only/ I /I/

/Relational

Page 6: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 6

Need to store some data ?

Oracle

SQL Server

Sybase

DB2

MySQL

PostgreSQL

Page 7: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 7

RDBMS are great for relational

storage !

Page 8: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 8

RDBMS may not be fully trivial…

…what a pity if you just wanted

a put / get store

Page 9: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 9

How to achievescalability and

high availabilitywith a RDMS ?

Page 10: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 10

Memcached can help to reduce the

pressure on RDBMS

Page 11: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 11

But this wasn’t enough for some

people…

Page 12: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 12

The birth of Dynamo at

Amazon.com…

Fill cart Checkout Payment Process order Prepare Send

Write must ALWAYS be available Only key-value is required

Temporal unavailability is acceptableRich storage is preferred for reporting

Page 13: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 13

So they started to create their own

database that would match their

needs… Table de hachage

persistante

Page 14: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 14

So they started to create their own

database that would match their

needs…

Table de hachage

persistante

Page 15: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 15

Consistent hashing spreads keys

uniformally across the partitions

Page 16: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 16

Sharding brings scalability,

replication brings high availability

Page 17: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 17

But failures still have to be handled

efficiently…

Page 18: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 18

In case of failure of a node, the 2 other nodes serve its load

Page 19: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 19

In this configuration,

clients know only few nodes which

act as proxy to other nodes…

Page 20: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 20

Gossip protocol to let everybody know node B has failed…

Page 21: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 21

Eventual consistency…

N = Number of replicas

R = Number of read responses to wait for

W = Number of write aknowledges to wait for

Page 22: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 22

The ratio between N, R and W makes

everything…

Page 23: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 23

The ratio between N, R and W makes

everything…

Page 24: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 24

The ratio between N, R and W makes

everything…

Page 25: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 25

Page 26: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 26

Key-value storesare simple…

Page 27: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 27

Several competitors…

Page 28: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 28

Riak…

Page 29: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 29

Riak…

Page 30: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 30

Document oriented databases are an evolution of key-

value stores

Page 31: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 31

MongoDB is the leader so far…

… 10gen said they are the « MySQL of

NoSQL »

Page 32: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 32

MongoDB is the leader so far…

Page 33: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 33

MongoDB is the leader so far…

Page 34: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 34

Graph databases are great to store…

graphs !

Page 35: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 35

Neo Technology is the leader so far

with Neo4j…

Page 36: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 36

Neo4j…

Page 37: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 37

Column-oriented databases have a

very particular data model…

Page 38: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 38

CassandraVs

HBase !

Page 39: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 39

Cassandra adds SuperColumns to

this model…

Page 40: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 40

Cassandra was developped at

Facebook, to store the user messages

Page 41: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 41

Now also used by Digg, Twitter, Rackspace,…

Page 42: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr

What a model…

Page 43: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 43

An example…

Page 44: Xebia Knowledge Exchange (may 2010) - NoSQL : Using the right tool for the right job

www.xebia.fr / blog.xebia.fr 44

Cassandra Demo