SlideShare uma empresa Scribd logo
1 de 65
Baixar para ler offline
NoSQL e Python
    @fmasanori
@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):
    – Business Intelligence/Data Warehouse
    – NoSQL databases
• Interesses: Python, NoSQL, Google
  Technology, Facebook
Conhecendo os assistentes

•   Python?
•   NoSQL?
•   pymongo?
•   redis-py?
•   pycassa?
Agenda

• Como comecei com NoSQL
• LucidDB: my first NoSQL
  experiment
• Flexible Schema
• Horizontal Scalability
• MongoDB (document)
• Redis (key-value)
• Cassandra (columnar)
• Demo
Como comecei com NoSQL
One Simple Idea

• Me ensinaram que tudo deveria ser
  normalizado...
• E que o mundo era SQL
• Mas um dia tive problemas:
  – Analytics
  – Twitter and Facebook data persistence
LucidDB

• 3 years ago
• Benchmark LucidDB x MySQL for
  Business Intelligence applications
• LucidDB: columnar NoSQL for BI
• Analytic applications:
  – Read only
  – Massive aggregations
  – Denormalization
Queries
              Queries
• Which movie genres generate the most
  revenue? (Q1)
• How is our revenue evolving over time?
  (Q2)
• At which time of day do costumers place
  the most orders? (Q3)
• How effective are the promotions we
  launch? (Q4)
Average time (ms)
35000




30000




25000




20000


                                      LucidDB

15000                                 MySQL




10000




5000




    0
        Q1       Q2     Q3       Q4
JSON persistence
Sentiment Analysis (Twitter)

menina: aaaaaaaaaaaaaa eu NAO GOSTO DELE
amiga: e vc ficará rica , e irá dividir sua riqueza cm sua amg aq
*u*
menina: kkkkkk como assim eu fikar rica pq?
amiga: pq ele é inteligente , e vai arranjar um ótimo emprego , e
ganhar mt dinheiro rs
menina: kkkkk ele é inteligente como assim ??
amiga: AQUELE VIADO PASSOU NO CASDINHO, E EU NÃO !
Sentiment Analysis (Facebook)


• Sabe o que é ter vontade de acordar cedo no
  domingo para estudar?!?
• Bom, eu também não sei explicar, mas é o que
  estou sentindo no momento .-.
• Bora Casdinho!
Social Data Change Fast
“Life begins at
   end of your
 comfort zone”
                   Neale Donald Walsch



     Slide EuroPython 2012
Python, Flask e MongoDB depois
      de 20 anos com .NET
“It’s better to think of
       NoSQL as a
   movement rather
  than a technology”
                  Martin Fowler
NoSQL vale a pena
Empregabilidade
Empregabilidade
Empregabilidade
O que as empresas esperam de um
            NoSQL?




      Dynamic Schema
O que as empresas esperam de um
            NoSQL?




      Flexible Schema
Relational DB
Relational DB




                Martin Fowler
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
Aggregate
 Model

Costumers
 Orders



    Martin Fowler
Aggregate
 Model


Costumers



    Martin Fowler
Scalability
If I had asked people
what they wanted, they
would have said faster
        horses.
                 Henry Ford.
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...)
Escalabilidade vertical
Escalabilidade horizontal
Escalabilidade horizontal
Dois artigos famosos

• Bigtable: A distributed storage
  system for structured data, 2006
• Dynamo: Amazon’s highly available
  key-value store, 2007
Apache Hadoop
Not Only SQL
There is no best NoSQL
•   JSON oriented
•   Autosharding
•   Full featured indexes
•   Great community
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/
• Data Structure Server
• In-memory dataset
• Persistence options
• CPU performance 175X (96)
• Os discos continuam iguais




• Memory 1M faster
• 1M = $1 (2000) x 1 cent (2010)
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
Cassandra:
 • Linearly Scalable
 • Column based
 • CQL
Martin Fowler
Cassandra vs MySQL (50GB)

MySQL:
 ~300ms write
 ~350ms read
Cassandra:
 ~0.12ms write
 ~15ms read
Relational DB




                (Timo Elliott, SAP)
Columnar DB




              (Timo Elliott, SAP)
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
Talk is cheap.
Show me the code.
             Linus Torvalds
MongoDB Server
Cassandra Server
Cassandra Server
Redis Server
Twitter and Facebook data




Obs.: não aparece o token de autenticação
Pymongo
Redis-py
Pycassa
Pymongo response
Redis-py response
Pycassa response
Bigliografia
Bigliografia
Bigliografia




Google IO 2012 - SQL vs NoSQL
   Battle of the Backends
Perguntas?
 fmasanori@gmail.com

facebook.com/fmasanori
 twitter.com/fmasanori

Mais conteúdo relacionado

Semelhante a NoSQL e Python RuPy 2012

Austin NoSQL 2011-07-06
Austin NoSQL 2011-07-06Austin NoSQL 2011-07-06
Austin NoSQL 2011-07-06
jimbojsb
 
Social Media, Cloud Computing, Machine Learning, Open Source, and Big Data An...
Social Media, Cloud Computing, Machine Learning, Open Source, and Big Data An...Social Media, Cloud Computing, Machine Learning, Open Source, and Big Data An...
Social Media, Cloud Computing, Machine Learning, Open Source, and Big Data An...
Open Analytics
 
Open Data Summit Presentation by Joe Olsen
Open Data Summit Presentation by Joe OlsenOpen Data Summit Presentation by Joe Olsen
Open Data Summit Presentation by Joe Olsen
Christopher Whitaker
 

Semelhante a NoSQL e Python RuPy 2012 (20)

Big Data! Great! Now What? #SymfonyCon 2014
Big Data! Great! Now What? #SymfonyCon 2014Big Data! Great! Now What? #SymfonyCon 2014
Big Data! Great! Now What? #SymfonyCon 2014
 
From a student to an apache committer practice of apache io tdb
From a student to an apache committer  practice of apache io tdbFrom a student to an apache committer  practice of apache io tdb
From a student to an apache committer practice of apache io tdb
 
Big Data vs Data Warehousing
Big Data vs Data WarehousingBig Data vs Data Warehousing
Big Data vs Data Warehousing
 
NoSQL
NoSQLNoSQL
NoSQL
 
Linked Data: The Real Web 2.0 (from 2008)
Linked Data: The Real Web 2.0 (from 2008)Linked Data: The Real Web 2.0 (from 2008)
Linked Data: The Real Web 2.0 (from 2008)
 
Why postgres SQL deserve noSQL fan respect - Riga dev day 2016
Why postgres SQL deserve noSQL fan respect - Riga dev day 2016Why postgres SQL deserve noSQL fan respect - Riga dev day 2016
Why postgres SQL deserve noSQL fan respect - Riga dev day 2016
 
Dibi Conference 2012
Dibi Conference 2012Dibi Conference 2012
Dibi Conference 2012
 
PlayStation and Lucene - Indexing 1M documents per second: Presented by Alexa...
PlayStation and Lucene - Indexing 1M documents per second: Presented by Alexa...PlayStation and Lucene - Indexing 1M documents per second: Presented by Alexa...
PlayStation and Lucene - Indexing 1M documents per second: Presented by Alexa...
 
Austin NoSQL 2011-07-06
Austin NoSQL 2011-07-06Austin NoSQL 2011-07-06
Austin NoSQL 2011-07-06
 
AWS re:Invent 2016| GAM302 | Sony PlayStation: Breaking the Bandwidth Barrier...
AWS re:Invent 2016| GAM302 | Sony PlayStation: Breaking the Bandwidth Barrier...AWS re:Invent 2016| GAM302 | Sony PlayStation: Breaking the Bandwidth Barrier...
AWS re:Invent 2016| GAM302 | Sony PlayStation: Breaking the Bandwidth Barrier...
 
Solr cloud the 'search first' nosql database extended deep dive
Solr cloud the 'search first' nosql database   extended deep diveSolr cloud the 'search first' nosql database   extended deep dive
Solr cloud the 'search first' nosql database extended deep dive
 
Your backend architecture is what matters slideshare
Your backend architecture is what matters slideshareYour backend architecture is what matters slideshare
Your backend architecture is what matters slideshare
 
Social Media, Cloud Computing, Machine Learning, Open Source, and Big Data An...
Social Media, Cloud Computing, Machine Learning, Open Source, and Big Data An...Social Media, Cloud Computing, Machine Learning, Open Source, and Big Data An...
Social Media, Cloud Computing, Machine Learning, Open Source, and Big Data An...
 
Open Data Summit Presentation by Joe Olsen
Open Data Summit Presentation by Joe OlsenOpen Data Summit Presentation by Joe Olsen
Open Data Summit Presentation by Joe Olsen
 
Big Data, Big Dream
Big Data, Big DreamBig Data, Big Dream
Big Data, Big Dream
 
PyData Texas 2015 Keynote
PyData Texas 2015 KeynotePyData Texas 2015 Keynote
PyData Texas 2015 Keynote
 
DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem
DownTheRabbitHole.js – How to Stay Sane in an Insane EcosystemDownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem
DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem
 
Myths & Reality - Choose a DBMS tailored to your use cases
Myths & Reality - Choose a DBMS tailored to your use casesMyths & Reality - Choose a DBMS tailored to your use cases
Myths & Reality - Choose a DBMS tailored to your use cases
 
DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem
DownTheRabbitHole.js – How to Stay Sane in an Insane EcosystemDownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem
DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem
 
Scaling a High Traffic Web Application: Our Journey from Java to PHP
Scaling a High Traffic Web Application: Our Journey from Java to PHPScaling a High Traffic Web Application: Our Journey from Java to PHP
Scaling a High Traffic Web Application: Our Journey from Java to PHP
 

Mais de FATEC São José dos Campos

Lista de exercícios III Desafios python para zumbis
Lista de exercícios III Desafios python para zumbisLista de exercícios III Desafios python para zumbis
Lista de exercícios III Desafios python para zumbis
FATEC São José dos Campos
 

Mais de FATEC São José dos Campos (20)

Seja feliz programando em python
Seja feliz programando em pythonSeja feliz programando em python
Seja feliz programando em python
 
Import community pycon jp
Import community pycon jpImport community pycon jp
Import community pycon jp
 
Import community
Import communityImport community
Import community
 
Diversidade na Comunidade Python
Diversidade na Comunidade PythonDiversidade na Comunidade Python
Diversidade na Comunidade Python
 
Why python
Why pythonWhy python
Why python
 
Hackeando Dados públicos com python
Hackeando Dados públicos com pythonHackeando Dados públicos com python
Hackeando Dados públicos com python
 
Import community
Import communityImport community
Import community
 
Python, the next Brazilian generation
Python, the next Brazilian generationPython, the next Brazilian generation
Python, the next Brazilian generation
 
Para gostar de Python DevDay
Para gostar de Python DevDay Para gostar de Python DevDay
Para gostar de Python DevDay
 
Classic Games with Python in the browser
Classic Games with Python in the browserClassic Games with Python in the browser
Classic Games with Python in the browser
 
Exercício Programa 1 Python para Zumbis
Exercício Programa 1 Python para ZumbisExercício Programa 1 Python para Zumbis
Exercício Programa 1 Python para Zumbis
 
Lista de exercícios V python para zumbis
Lista de exercícios V python para zumbisLista de exercícios V python para zumbis
Lista de exercícios V python para zumbis
 
Lista de exercícios IV python para zumbis
Lista de exercícios IV python para zumbisLista de exercícios IV python para zumbis
Lista de exercícios IV python para zumbis
 
Lista de exercícios III Desafios python para zumbis
Lista de exercícios III Desafios python para zumbisLista de exercícios III Desafios python para zumbis
Lista de exercícios III Desafios python para zumbis
 
Lista de exercícios II python para zumbis
Lista de exercícios II python para zumbisLista de exercícios II python para zumbis
Lista de exercícios II python para zumbis
 
Lista de exercícios XIV Python para Zumbis
Lista de exercícios XIV Python para ZumbisLista de exercícios XIV Python para Zumbis
Lista de exercícios XIV Python para Zumbis
 
TWP56 DJ Mix 1
TWP56 DJ Mix 1TWP56 DJ Mix 1
TWP56 DJ Mix 1
 
TWP54 Exceções
TWP54 ExceçõesTWP54 Exceções
TWP54 Exceções
 
TWP52 MVC Model View Controller
TWP52 MVC Model View ControllerTWP52 MVC Model View Controller
TWP52 MVC Model View Controller
 
TWP50 Interface Gráfica GUI
TWP50 Interface Gráfica GUITWP50 Interface Gráfica GUI
TWP50 Interface Gráfica GUI
 

Último

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Último (20)

How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 

NoSQL e Python RuPy 2012