NoSQL:
Perdas e
           Mauricio De Diana
Ganhos     mdediana@ime.usp.br
Arquitetura
Trade-offs
Latência
Vazão
Segurança
...
Manutenibilidade
Testabilidade
Modelo de dados




Performance / Escalabilidade
NOSQL: scaling to size and scaling to complexity
http://blogs.neotechnology.com/emil/2009/11/nosql-scaling-to-size-and-scaling-to-complexity.html
Bigtable

"Bigtable is a distributed storage system for managing
structured data that is designed to scale to a very large size:
petabytes of data across thousands                       of commodity
servers."



Bigtable: A Distributed Storage System for Structured Data [2006]
Dynamo

"Reliability at massive scale is one of the biggest
challenges we face at Amazon.com [...]. The Amazon.com
platform [...] is implemented on top of an infrastructure of
tens of thousands of servers and network
components located in many               datacenters around the
world."



Dynamo: Amazon's Highly Available Key-value Store [2007]
Modelo de dados
Modelo mais adequado

              Impedância Objeto-Relacional

              Grafos: interconectividade dos
              dados é tão ou mais importante
              quanto os dados em si

              Modelos simples: chave-valor
Relacional

Esquema

Restrições de integridade
(pks, fks, tipos e valores)

Normalização
NoSQL and SQL Anti Patterns

Dynamic table creation

Row alignment

Extreme joins




http://www.slideshare.net/gleicon/nosql-and-sql-anti-patterns
Dados semi-estruturados
Estrutura heterogênea

Estrutura parcial

Esquemas que evoluem rapidamente

Distinção pouco clara entre esquema e dados
Shared Database




http://www.eaipatterns.com/SharedDataBaseIntegration.html
Performance /
Escalabilidade
Escalar relacional
N web servers
1 db
master / slave
master / slave
functional partitioning
sharding
Joins
        Integridade referencial
        Auto-increment
        Normalização


e ainda carrega todo o peso de um RDMBS
One size fits all?




"One Size Fits All": An Idea Whose Time Has Come and Gone [2005]
One size does not fit all

OLTP                    OLAP

Operação                Informação (BI)

CRUD pequeno e rápido   Batches demorados

Queries simples         Queries complexas
One size does not fit all

OLTP                                            OLAP

                                                C-Store
H-Store




The End of an Architectural Era (It's Time for a Complete Rewrite) [2007]
C-store: a Column-oriented DBMS [2005]
Transações

Atomicidade
Consistência
Isolamento
Durabilidade
Teorema CAP

 Consistency
 Availability
 Partition Tolerance


Towards Robust Distributed Systems [2000]
Brewer's Conjecture and the Feasibility of Consistent, Available, Partition-tolerant Web
Services [2002]
ACID x BASE

Basically Available
Soft state
Eventual consistency


BASE: An Acid Alternative [2008]
Eventually Consistent [2009]
eventual en                X        eventual pt

Occurring at an unspecified       Dependente de acontecimento
time in the future                incerto; casual; fortuito; possível
                                  mas incerto.
Workarounds

  Não fazer nada

  Ações de compensação




Starbucks Does Not Use Two-Phase Commit
http://www.eaipatterns.com/ramblings/18_starbucks.html
Polyglot persistence
Obrigado




           mdediana@ime.usp.br

NoSQL: Perdas e Ganhos