conceptos básicos. seminario web 1: introducción a nosql
TRANSCRIPT
![Page 1: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/1.jpg)
![Page 2: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/2.jpg)
![Page 3: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/3.jpg)
Back to Basics 2016: Webinar 1Introducción a NoSQL
Rubén TerceñoSenior Solutions Architect, [email protected]@rubenTerceno
![Page 4: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/4.jpg)
¡Bienvenidos!
![Page 5: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/5.jpg)
Agenda del CursoDate Time Webinar25-Mayo-2016 16:00 CEST Introducción a NoSQL 7-Junio-2016 16:00 CEST Su primera aplicación MongoDB 21-Junio-2016 16:00 CEST Diseño de esquema orientado a documentos 07-Julio-2016 16:00 CEST Indexación avanzada, índices de texto y geoespaciales 19-Julio-2016 16:00 CEST Introducción al Aggregation Framework 28-Julio-2016 16:00 CEST Despliegue en producción
![Page 6: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/6.jpg)
Agenda de hoy• ¿Porqué existe NoSQL?
• Tipos de bases de datos NoSQL
• Características clave de MongoDB
• Tolerancia a fallos y persistencia de datos en MongoDB
• Escalabilidad en MongoDB
• Preguntas
![Page 7: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/7.jpg)
The origin of SQL (1979)
250 Mb$ 81.000/year
Dennis RitchieBrian Kernighan$ 8.000/year … (both)
![Page 8: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/8.jpg)
Relational
Expressive Query Language& Secondary Indexes
Strong Consistency
Enterprise Management& Integrations
![Page 9: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/9.jpg)
The World Has ChangedData Risk Time Cost
![Page 10: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/10.jpg)
The origin of NoSQL
•Google y Amazon• Sistemas distribuídos• Open source• No relacionales
•2009 twitter hashtag #nosql
![Page 11: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/11.jpg)
Scalability& Performance
Always On,Global Deployments
FlexibilityExpressive Query Language& Secondary Indexes
Strong Consistency
Enterprise Management& Integrations
NoSQL
![Page 12: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/12.jpg)
Types of NoSQL Database
•Key/Value Stores
•Column Stores
•Graph Stores
•Multi-model Databases
•Document Stores
![Page 13: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/13.jpg)
Consistency vs Availability
Reservas
NY…
Reservas
NY…
1 1
![Page 14: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/14.jpg)
Key Value Stores• An associative array
• Single key lookup
• Very fast single key lookup
• Not so hot for “reverse lookups”Key Value12345 4567.345678712346 { addr1 : “The Grange”, addr2: “Dublin” }12347 “top secret password”12358 “Shopping basket value : 24560”12787 12345
![Page 15: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/15.jpg)
Revision : Row Stores (RDBMS)• Store data aligned by rows (traditional RDBMS, e.g MySQL)• Reads retrieve a complete row every time• Reads requiring only one or two columns are wasteful
ID Name Salary Start Date
1 Ruben T $24000 1/Jun/1970
2 Peter J $28000 1/Feb/1972
3 Phil G $23000 1/Jan/1973
1 Ruben T $24000 1/Jun/1970
2 Peter J $28000 1/Feb/1972 3 Phil G $23000 1/Jan/1973
![Page 16: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/16.jpg)
How a Column Store Does it
1 2 3
ID Name Salary Start Date
1 Ruben T $24000 1/Jun/1970
2 Peter J $28000 1/Feb/1972
3 Phil G $23000 1/Jan/1973
Ruben T Peter J Phil G $24000 $28000 $23000 1/Jun/1970 1/Feb/1972 1/Jan/1973
![Page 17: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/17.jpg)
Why is this Attractive?• A series of consecutive seeks can retrieve a column efficiently
• Compressing similar data is super efficient
• So reads can grab more data off disk in a single seek
• How do I align my rows? By order or by inserting a row ID
• IF you just need a small number of columns you don’t need to read all the rows
• But Updating and deleting by row is expensive
• Append only is preferred
• Better for OLAP than OLTP
![Page 18: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/18.jpg)
Graph Stores• Store graphs (edges and vertexes)
• E.g. social networks
• Designed to allow efficient traversal
• Optimised for representing connections
• Can be implemented as a key value stored with the ability to store links
• If your use case is not a graph you don’t need a graph database
![Page 19: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/19.jpg)
Multi-Model Databases• Combine multiple storage/access models
• Often Graph plus “something else”
• Fixes the “polyglot persistence” issue of keeping multiple independent databases consistent
• The “new new thing” in NoSQL Land
• Expect to hear more noise about these kinds of databases
![Page 20: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/20.jpg)
Document Store• Not PDFs, Microsoft Word or HTML• Documents are nested structures created using Javascript Object Notation (JSON)
{ name : “Rubén Terceño”,title : “Senior Solutions Architect”,employee_number : 653,location : { type : “Point”,coordinates : [ 43.34, -3.26 ]},expertise: [ “MongoDB”, “Java”, “Geospatial” ],address : {address1 : “Rutilo 11”,address2 : “Piso 1, Oficina 2”,zipcode : “28041”,}}
![Page 21: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/21.jpg)
Documents are Rich Structures{
name : “Rubén Terceño”,
title : “Senior Solutions Architect”,
employee_number : 653,
location : {
type : “Point”,
coordinates : [ 43.34, -3.26 ]},
expertise: [ “MongoDB”, “Java”, “Geospatial” ],
address : {
address1 : “Rutilo 11”,
address2 : “Piso 1, Oficina 2”,
zipcode : “28041”,
}
}
Fields can contain sub-documents
Typed field values
Fields can contain arrays
String
Number
Geo-Location
Fields
![Page 22: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/22.jpg)
• From the very first version it was a native JSON database
• Understands and can index the sub-structures
• Stores JSON as an serialized binary format called BSON
• Efficient for encoding and decoding for network transmission
• MongoDB can create indexes on any document field
• (We will cover these areas in detail later on in the course)
MongoDB really speaks JSON
![Page 23: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/23.jpg)
MongoDB is Full-Featured
Rich Queries Find all Solution Architects
Find all employees knowing Java in Support or Consulting
Geospatial Find all the employees currently in France
Text Search Find all employees describing themselves as “self-driven”
Aggregation Calculate the average distance to the Office for all employees
Map Reduce What are the most common skills by region over time (is node.js trending in Brasil?)
![Page 24: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/24.jpg)
Nexus Architecture
Scalability& Performance
Always On,Global Deployments
FlexibilityExpressive Query Language& Secondary Indexes
Strong Consistency
Enterprise Management& Integrations
![Page 25: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/25.jpg)
Development – The Past
{ CODE } DB SCHEMAXML CONFIG
APPLICATION RELATIONAL DATABASEOBJECT RELATIONAL MAPPING
![Page 26: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/26.jpg)
Development – With MongoDB
{ CODE } DB SCHEMAXML CONFIG
APPLICATION RELATIONAL DATABASEOBJECT RELATIONAL MAPPING
![Page 27: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/27.jpg)
Replica Sets
• Replica set – 2 to 50 copies• Replica sets make up a self-healing ‘shard’• Data center awareness• Replica sets address:
• High availability• Data durability, consistency• Maintenance (e.g., HW swaps)• Disaster Recovery
Application
Driver
Primary
Secondary
Secondary
Replication
![Page 28: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/28.jpg)
Replica Sets – Workload Isolation
• Replica sets enable workload isolation• Example: Operational workloads on the
primary node, analytical workloads on the secondary nodes
eCommerce Application
MongoDB PrimaryIn-memory Storage Engine
MongoDB SecondaryWiredTiger Storage Engine
User DataSessions, Cart,Recommendations
MongoDB SecondaryWiredTiger Storage Engine
PersistedUser Data
![Page 29: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/29.jpg)
Node 1
Node 2 Node 3
Replica Set Creation
![Page 30: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/30.jpg)
Node 1(Primary)
Node 2(Secondary)
Node 3(Secondary)
Replication Replication
Heartbeat
Replica Set - Initialize
![Page 31: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/31.jpg)
Node 2(Secondary)
Node 3(Secondary)
Heartbeat
Primary Election
Node 1(Primary)
Replica Set - Failure
![Page 32: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/32.jpg)
Node 1(Primary)
Node 2(Primary)
Node 3(Secondary)
Heartbeat
Replication
Replica Set - Failover
![Page 33: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/33.jpg)
Node 2(Primary)
Node 3(Secondary)
Heartbeat
Replication
Node 1(Recovery)
Replication
Replica Set - Recovery
![Page 34: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/34.jpg)
Node 2(Primary)
Node 3(Secondary)
Heartbeat
Replication
Node 1(Secondary)
Replication
Replica Set - Recovered
![Page 35: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/35.jpg)
Elastic Scalability: Automatic Sharding
• Increase or decrease capacity as you go
• Automatic load balancing
• Three types of sharding
• Hash-based
• Range-based
• Tag-aware
Shard 1 Shard 2 Shard 3 Shard N
Horizontally Scalable
![Page 36: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/36.jpg)
Scalability with Sharding• Shard key partitions the content
• MongoDB automatically balances the cluster
• Shards can be added dynamically to a live system
• Rebalancing happens in the background
• Shard key is immutable
• Shard key can route queries to a specific shard
• Queries without a shard key are sent to all members• Each member process its part in parallel.
![Page 37: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/37.jpg)
Query Routing
• Multiple query optimization models
• Each of the sharding options are
appropriate for different apps / use
cases
![Page 38: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/38.jpg)
Query Routing• With a sharded cluster we use a routing layer to guide queries
• We use a daemon called MongoS (Mongo Shard Router)
• Daemon is stateless
• Can run as many as required
• Typically one per app server
![Page 39: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/39.jpg)
Resumen• ¿Porqué existe NoSQL?• Tipos de bases de datos NoSQL• Características clave de MongoDB• Tolerancia a fallos y persistencia de datos en MongoDB• Escalabilidad en MongoDB
![Page 40: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/40.jpg)
Próximo WebinarSu primera aplicación MongoDB
• 7 de Junio 2016 – 16:00 GMT, 11:00, 9:00• ¡Regístrese si aún no lo ha hecho!• Aprenda cómo construir tu primera aplicación con MongoDB
• Cree bases de datos y colecciones• Cree queries• Construya Índices• Entienda cómo analizar el rendimiento
• Regístrese en : https://www.mongodb.com/webinars• Denos su opinión, por favor: [email protected]
![Page 41: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/41.jpg)
¿Preguntas?
![Page 42: Conceptos básicos. Seminario web 1: Introducción a NoSQL](https://reader033.vdocuments.co/reader033/viewer/2022042604/5873ec901a28abb1528b46fd/html5/thumbnails/42.jpg)