Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
MongoDBEurope2016
Old Billingsgate, London
15th November
Use my code rubenterceno20 for 20% off tickets
mongodb.com/europe
Conceptos Básicos 2016
Despliegue en Producción
Rubén Terceño
Senior Solutions Architect, EMEA
ruben@mongodb.com
@rubenTer...
Agenda del Curso
Date Time Webinar
25-Mayo-2016 16:00 CEST Introducción a NoSQL
7-Junio-2016 16:00 CEST Su primera aplicac...
Resumen de lo visto hasta ahora
• ¿Porqué existe NoSQL?
• Características clave de MongoDB
• Instalación y creación de bas...
Production Checklist
•Alta Disponibilidad
•Escalabilidad Horizontal
•Monitorización y Performance Tuning
•Backup y Recover...
Replica Sets
• Replica set – 2 to 50 copies
• Replica sets make up a self-healing ‘shard’
• Data center awareness
• Replic...
Replica Sets – Workload Isolation
• Replica sets enable workload isolation
• Example: Operational workloads on the primary...
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
writeConcern & readConcern
• writeConcern
• Configurable level of acknowledgement
• { w: <value>, j: <boolean>, wtimeout: ...
Node 1
(Primary)
Node 2
(Secondary)
Node 3
(Secondary)
Application
Driver
Read and write
Strong Consistency
Node 1
(Primary)
Node 2
(Secondary)
Node 3
(Secondary)
Application
Driver
Strong Consistency
Read Read
Read and write
readPreference
• Read preference describes how MongoDB clients route
read operations to the members of a replica set.
• pr...
Elastic Scalability: Automatic Sharding
• Increase or decrease capacity as you go
• Automatic load balancing
• Three types...
Query Routing
• Multiple query optimization models
• Each of the sharding options are appropriate
for different apps / use...
Sharding key
• Sharding key is the way MongoDB partition collections.
• The range of the sharding key is split in several ...
Selecting a sharding key
• Probably the most influential decision on performance
• A good sharding key has:
• High cardina...
Config servers and mongos
• Config servers store metadata (chunk distribution and location)
• The can be configured as a r...
Sharding, when?
• Shard only when needed:
• Vertical scalability is not possible anymore
• RAM
• CPU
• IOPS
• Concurrency
...
Monitoring
• MongoDB offers tools for monitoring the cluster performance
• mongostats
• Shows operations per second, memor...
Profiling
• Database profiler
• db.setProfilingLevel(<level>,slowOpThresholdMs)
• level 0: Profiler off. Slow operations a...
Logs
• Logs
• db.setLogLevel(<level>, <component>)
• level 0-5 : Different verbosity levels
• level -1 : Inherits verbosit...
Backup – mongodump
• Generates a BSON file and a JSON metadata file.
• Better done from a secondary
• Potentially generate...
Backup – file system copy/snapshot
• Copy files on your data directory
• Lock the database first!!
• Fastest way to restor...
Security
• MongoDB is unsecured by default
• It’s up to you to use the provided security mechanism
• Authentication  User...
MongoDB – We’re here to help
Security License SupportTooling Services
MongoDB Compass MongoDB Connector for BI
MongoDB Enterprise Server
MongoDB Enterprise Advanced
CommercialLicense
(NoAGPLCo...
MongoDB Atlas
Database as a service for MongoDB
MongoDB Atlas is…
• Automated: The easiest way to build, launch, and scale...
Summary
• Los Replica Sets permiten alta disponibilidad y facilitan las
operaciones de mantenimiento.
• writeConcern, read...
¿Ya no hay más webinars?
• Sigue habiendo webinars en https://www.mongodb.com/webinars
• Si quiere aprender más sobre mong...
¿Preguntas?
Conceptos básicos. Seminario web 6: Despliegue de producción
Conceptos básicos. Seminario web 6: Despliegue de producción
Upcoming SlideShare
Loading in …5
×

Conceptos básicos. Seminario web 6: Despliegue de producción

1,221 views

Published on

Este es el último seminario web de la serie Conceptos básicos, en la que se realiza una introducción a la base de datos MongoDB. En este seminario web le guiaremos por el despliegue en producción.

Published in: Data & Analytics
  • Be the first to comment

Conceptos básicos. Seminario web 6: Despliegue de producción

  1. 1. MongoDBEurope2016 Old Billingsgate, London 15th November Use my code rubenterceno20 for 20% off tickets mongodb.com/europe
  2. 2. Conceptos Básicos 2016 Despliegue en Producción Rubén Terceño Senior Solutions Architect, EMEA ruben@mongodb.com @rubenTerceno
  3. 3. Agenda del Curso Date Time Webinar 25-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
  4. 4. Resumen de lo visto hasta ahora • ¿Porqué existe NoSQL? • Características clave de MongoDB • Instalación y creación de bases de datos y colecciones • Operaciones CRUD, Índices y explain() • Diseño de esquema dinámico • Jerarquía y documentos embebidos • Búsquedas de texto libre y geoespaciales • Pipeline de Agregación
  5. 5. Production Checklist •Alta Disponibilidad •Escalabilidad Horizontal •Monitorización y Performance Tuning •Backup y Recovery •Seguridad
  6. 6. 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
  7. 7. 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 Primary In-memory Storage Engine MongoDB Secondary WiredTiger Storage Engine User Data Sessions, Cart, Recommendations MongoDB Secondary WiredTiger Storage Engine Persisted User Data
  8. 8. Node 1 Node 2 Node 3 Replica Set Creation
  9. 9. Node 1 (Primary) Node 2 (Secondary) Node 3 (Secondary) Replication Replication Heartbeat Replica Set - Initialize
  10. 10. Node 2 (Secondary) Node 3 (Secondary) Heartbeat Primary Election Node 1 (Primary) Replica Set - Failure
  11. 11. Node 1 (Primary) Node 2 (Primary) Node 3 (Secondary) Heartbeat Replication Replica Set - Failover
  12. 12. Node 2 (Primary) Node 3 (Secondary) Heartbeat Replication Node 1 (Recovery) Replication Replica Set - Recovery
  13. 13. Node 2 (Primary) Node 3 (Secondary) Heartbeat Replication Node 1 (Secondary) Replication Replica Set - Recovered
  14. 14. writeConcern & readConcern • writeConcern • Configurable level of acknowledgement • { w: <value>, j: <boolean>, wtimeout: <number> } • w  1, n, majority, tag • readConcern • Configurable level of read isolation • readConcern: { level: <"majority"|"local"> }
  15. 15. Node 1 (Primary) Node 2 (Secondary) Node 3 (Secondary) Application Driver Read and write Strong Consistency
  16. 16. Node 1 (Primary) Node 2 (Secondary) Node 3 (Secondary) Application Driver Strong Consistency Read Read Read and write
  17. 17. readPreference • Read preference describes how MongoDB clients route read operations to the members of a replica set. • primary • primaryPreferred • secondary • secondaryPreferred • nearest • tags
  18. 18. 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
  19. 19. Query Routing • Multiple query optimization models • Each of the sharding options are appropriate for different apps / use cases
  20. 20. Sharding key • Sharding key is the way MongoDB partition collections. • The range of the sharding key is split in several chunks. • The chunks are distributed evenly among the available shards
  21. 21. Selecting a sharding key • Probably the most influential decision on performance • A good sharding key has: • High cardinality • Evenly distributed frequency • A non-monotonic creation rate • And much more important: is used on queries. • Limitations • Sharding key is immutable • Sharding key values are immutable • Sharding key can’t be a multikey, geospatial or text index
  22. 22. Config servers and mongos • Config servers store metadata (chunk distribution and location) • The can be configured as a replica set from version 3.2 (CSRS) • Up to 50 config servers • Hardened failover • mongos acts as query routers • mongos keep a local copy of config server information • mongos can be deployed on the application server
  23. 23. Sharding, when? • Shard only when needed: • Vertical scalability is not possible anymore • RAM • CPU • IOPS • Concurrency • Depending on the server technology the range to start thinking in sharding is around a few Tb of data.
  24. 24. Monitoring • MongoDB offers tools for monitoring the cluster performance • mongostats • Shows operations per second, memory usage, page faults, queues and more • mongotop • Provides statistics on a per collection basis • Mongo Shell • db.serverStatus() • db.serverStatus({ workingSet : 1 })
  25. 25. Profiling • Database profiler • db.setProfilingLevel(<level>,slowOpThresholdMs) • level 0: Profiler off. Slow operations are always written to the log (default) • level 1: Collects data for operations slower than the threshold • level 2: Collect information for all operations • Profile info is on system.profile collection on admin database
  26. 26. Logs • Logs • db.setLogLevel(<level>, <component>) • level 0-5 : Different verbosity levels • level -1 : Inherits verbosity from parent • https://docs.mongodb.com/manual/reference/log-messages/#components • In order to analyze the log information you can use mtools • https://github.com/rueckstiess/mtools • Not supported by MongoDB, but built by MongoDB employees and used internally (a lot)
  27. 27. Backup – mongodump • Generates a BSON file and a JSON metadata file. • Better done from a secondary • Potentially generates inconsistent data • Lock the database during dump  db.fsyncLock() & db.fsyncUnlock() • Disconnect a secondary node temporally • Use the -oplog and -oplogReplay options • mongodump -h myhost –oplog • mongorestore –h myhost –oplogReplay ./cms/dump • Simple but slow for both backup and restore
  28. 28. Backup – file system copy/snapshot • Copy files on your data directory • Lock the database first!! • Fastest way to restore • Challenging on a sharded environment • Disable the chunks balancer  sh.setBalancerState(false) • Backup each shard • Backup the config servers
  29. 29. Security • MongoDB is unsecured by default • It’s up to you to use the provided security mechanism • Authentication  Users, Certificates • Authorization  Roles • Encrypt communications  TLS/SSL • Limit network exposure  bindIp • Use dedicated OS users. • … • Read the security checklist: https://docs.mongodb.com/manual/administration/security-checklist/
  30. 30. MongoDB – We’re here to help Security License SupportTooling Services
  31. 31. MongoDB Compass MongoDB Connector for BI MongoDB Enterprise Server MongoDB Enterprise Advanced CommercialLicense (NoAGPLCopyleftRestrictions) Platform Certifications MongoDB Ops Manager Monitoring & Alerting Query Optimization Backup & Recovery Automation & Configuration Schema Visualization Data Exploration Ad-Hoc Queries Visualization Analysis Reporting LDAP & Kerberos Auditing FIPS 140-2Encryption at Rest REST APIEmergency Patches Customer Success Program On-Demand Online Training Warranty Limitation of Liability Indemnification 24x7Support (1hourSLA)
  32. 32. MongoDB Atlas Database as a service for MongoDB MongoDB Atlas is… • Automated: The easiest way to build, launch, and scale apps on MongoDB • Flexible: The only database as a service with all you need for modern applications • Secured: Multiple levels of security available to give you peace of mind • Scalable: Deliver massive scalability with zero downtime as you grow • Highly available: Your deployments are fault-tolerant and self-healing by default • High performance: The performance you need for your most demanding workloads
  33. 33. Summary • Los Replica Sets permiten alta disponibilidad y facilitan las operaciones de mantenimiento. • writeConcern, readConcern y readPreference permiten controlar la persistencia y consistencia de los datos. • El sharding permite escalar horizontalmente • La selección de una buena clave de sharding es la clave. • MongoDB ofrece herramientas para monitorizar y controlar el rendimiento de la base de datos, así como para generar los backups • ¡La seguridad es lo primero! Usuarios, roles y encriptación • MongoDB proporciona todas la herramientas requeridas para operar su despliegue en producción con seguridad y de manera profesional.
  34. 34. ¿Ya no hay más webinars? • Sigue habiendo webinars en https://www.mongodb.com/webinars • Si quiere aprender más sobre mongodb: • University: https://university.mongodb.com/ • Si quiere demostrar el mundo lo que sabe: • Certificaciones: https://university.mongodb.com/exams • Si quiere conocer otras personas que usan mongodb: • MongoDB User Groups (MUGs): http://www.meetup.com/pro/mongodb/ • Denos su opinión, por favor: back-to-basics@mongodb.com
  35. 35. ¿Preguntas?

×