conceptos básicos. seminario web 1: introducción a nosql

Post on 21-Apr-2017

7.644 Views

Category:

Data & Analytics

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Back to Basics 2016: Webinar 1Introducción a NoSQL

Rubén TerceñoSenior Solutions Architect, EMEAruben@mongodb.com@rubenTerceno

¡Bienvenidos!

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

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

The origin of SQL (1979)

250 Mb$ 81.000/year

Dennis RitchieBrian Kernighan$ 8.000/year … (both)

Relational

Expressive Query Language& Secondary Indexes

Strong Consistency

Enterprise Management& Integrations

The World Has ChangedData Risk Time Cost

The origin of NoSQL

•Google y Amazon• Sistemas distribuídos• Open source• No relacionales

•2009 twitter hashtag #nosql

Scalability& Performance

Always On,Global Deployments

FlexibilityExpressive Query Language& Secondary Indexes

Strong Consistency

Enterprise Management& Integrations

NoSQL

Types of NoSQL Database

•Key/Value Stores

•Column Stores

•Graph Stores

•Multi-model Databases

•Document Stores

Consistency vs Availability

Reservas

NY…

Reservas

NY…

1 1

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

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

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

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

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

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

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”,}}

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

• 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

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?)

Nexus Architecture

Scalability& Performance

Always On,Global Deployments

FlexibilityExpressive Query Language& Secondary Indexes

Strong Consistency

Enterprise Management& Integrations

Development – The Past

{ CODE } DB SCHEMAXML CONFIG

APPLICATION RELATIONAL DATABASEOBJECT RELATIONAL MAPPING

Development – With MongoDB

{ CODE } DB SCHEMAXML CONFIG

APPLICATION RELATIONAL DATABASEOBJECT RELATIONAL MAPPING

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

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

Node 1

Node 2 Node 3

Replica Set Creation

Node 1(Primary)

Node 2(Secondary)

Node 3(Secondary)

Replication Replication

Heartbeat

Replica Set - Initialize

Node 2(Secondary)

Node 3(Secondary)

Heartbeat

Primary Election

Node 1(Primary)

Replica Set - Failure

Node 1(Primary)

Node 2(Primary)

Node 3(Secondary)

Heartbeat

Replication

Replica Set - Failover

Node 2(Primary)

Node 3(Secondary)

Heartbeat

Replication

Node 1(Recovery)

Replication

Replica Set - Recovery

Node 2(Primary)

Node 3(Secondary)

Heartbeat

Replication

Node 1(Secondary)

Replication

Replica Set - Recovered

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

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.

Query Routing

• Multiple query optimization models

• Each of the sharding options are

appropriate for different apps / use

cases

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

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

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: back-to-basics@mongodb.com

¿Preguntas?

top related