hello nosql world

55
Hello NoSQL World PythonBrasil[8] @fmasanori http://www.slideshare.net/fmasanori

Upload: fernando-masanori

Post on 18-Dec-2014

1.140 views

Category:

Education


0 download

DESCRIPTION

A brief introduction to NoSQL World. MongoDB, Cassandra, Redis.

TRANSCRIPT

Page 1: Hello NoSQL World

Hello NoSQL World

PythonBrasil[8] @fmasanori

http://www.slideshare.net/fmasanori

Page 2: Hello NoSQL World

@fmasanori

• Graduado IME-USP e Mestrado ITA

• ed e lint Cobra Tecnologia

• Software Express

• Credicard Mastercard

• PriceWaterhouseCoopers

• Itau BankBoston

• Docente FATEC SJC (amo dar aulas)

• Interesses: Python, NoSQL, Google Technology, Facebook

Page 3: Hello NoSQL World
Page 4: Hello NoSQL World

Conhecendo os assistentes

• NoSQL?

• pymongo?

• redis-py?

• pycassa?

Page 5: Hello NoSQL World

Agenda

• Dynamic/Flexible Schema

• Vertical Scalability

• Horizontal Scalability

• Document -> Mongo

• Key-value -> Redis

• Columnar -> Cassandra

• Demo

Page 7: Hello NoSQL World

“It’s better to think of NoSQL as a

movement rather

than a technology” Martin Fowler

Page 8: Hello NoSQL World

NoSQL vale a pena

Page 9: Hello NoSQL World

Job Trends (indeed.com)

Page 10: Hello NoSQL World

Job Trends (indeed.com)

Page 11: Hello NoSQL World

Job Trends (indeed.com)

Page 12: Hello NoSQL World

O que as empresas esperam de um NoSQL?

Dynamic Schema

Page 13: Hello NoSQL World

Flexible Schema

O que as empresas esperam de um NoSQL?

Page 14: Hello NoSQL World

Relational DB

Page 15: Hello NoSQL World

Impedance mismatch

• The difference between the relational model and the in-memory data structures (Fowler)

• Limitations of relational DB: values only in tuples

• We need a more complex structure than a set of tuples as a data unit

Page 16: Hello NoSQL World

Relational DB

Martin Fowler

Page 17: Hello NoSQL World

Costumers Orders

Martin Fowler

Aggregate Model

Page 18: Hello NoSQL World

Costumers

Martin Fowler

Aggregate Model

Page 19: Hello NoSQL World

Scalability

Page 20: Hello NoSQL World

If I had asked people what they wanted, they would have said faster

horses. Henry Ford.

Page 21: Hello NoSQL World

Escalabilidade vertical

• Escalabilidade para leituras num banco relacional: trabalhoso

• Escalabilidade para escritas num banco relacional: MUITO, MUITO, trabalhoso

• (se conseguir seu BD deixou de ser relacional...)

Page 22: Hello NoSQL World

Escalabilidade vertical

Page 23: Hello NoSQL World

Escalabilidade horizontal

Page 24: Hello NoSQL World

Escalabilidade horizontal

Page 25: Hello NoSQL World

Dois artigos famosos

• Bigtable: A distributed storage system for structured data, 2006

• Dynamo: Amazon’s highly available key-value store, 2007

Page 26: Hello NoSQL World

Apache Hadoop

Page 27: Hello NoSQL World

Not Only SQL

Page 28: Hello NoSQL World

There is no best NoSQL

Page 29: Hello NoSQL World

• JSON oriented • Autosharding • Full featured indexes

Page 30: Hello NoSQL World

Dowload and install:

http://www.mongodb.org/downloads

Criar c:/data/db

Servidor:

bin/mongod

Cliente:

bin/mongo

Cliente pymongo:

http://api.mongodb.org/python/current/

import pymongo

Curso completo MongoDB com Python:

http://education.10gen.com/

Page 31: Hello NoSQL World

Cassandra: • Linearly Scalable • Column based

Page 32: Hello NoSQL World

Martin Fowler

Page 33: Hello NoSQL World

Cassandra vs MySQL (50GB)

MySQL:

~300ms write

~350ms read

Cassandra:

~0.12ms write

~15ms read

Page 34: Hello NoSQL World
Page 35: Hello NoSQL World

Banco Relacional Tradicional

(Timo Elliott, SAP)

Page 36: Hello NoSQL World

Banco Colunar

(Timo Elliott, SAP)

Page 37: Hello NoSQL World

Download DataStax Community Edition

Servidor:

cassandra

Cliente:

cassandra-cli –h localhost –p 9160

Conflitos:

cassandra.bat (windows)

/etc/cassandra/cassandra-env.sh (ubuntu)

Cliente pycassa:

https://github.com/pycassa/pycassa/downloads

import pycassa

Page 38: Hello NoSQL World

• Data Structure Server • In-memory dataset

Page 39: Hello NoSQL World

• CPU performance 175X (96) • Os discos continuam iguais • Memory 1M faster • 1M = $1 (2000) x 1 cent (2010)

Page 40: Hello NoSQL World

http://redis.io/download

https://github.com/MSOpenTech/redis

(for Windows)

Servidor:

redis-server

Cliente:

redis-cli

Cliente redis-py:

https://github.com/andymccurdy/redis-py

import redis

Page 41: Hello NoSQL World

Talk is cheap.

Show me the code. Linus Torvalds

Page 42: Hello NoSQL World

Servidor MongoDB

Page 43: Hello NoSQL World

Servidor Cassandra

Page 44: Hello NoSQL World

Servidor Cassandra

Page 45: Hello NoSQL World

Servidor Redis

Page 46: Hello NoSQL World

Dados Facebook e Twitter

Page 47: Hello NoSQL World

Pymongo

Page 48: Hello NoSQL World

Redis-py

Page 49: Hello NoSQL World

Pycassa

Page 50: Hello NoSQL World

Pymongo response

Page 51: Hello NoSQL World

Redis-py response

Page 52: Hello NoSQL World

Pycassa response

Page 53: Hello NoSQL World

Bibliografia