VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation MongoDB Architecture.

Slides:



Advertisements
Similar presentations
PNUTS: Yahoo’s Hosted Data Serving Platform Jonathan Danaparamita jdanap at umich dot edu University of Michigan EECS 584, Fall Some slides/illustrations.
Advertisements

The Google File System. Why? Google has lots of data –Cannot fit in traditional file system –Spans hundreds (thousands) of servers connected to (tens.
Data Indexing Herbert A. Evans. Purposes of Data Indexing What is Data Indexing? Why is it important?
Distributed Systems Fall 2009 Replication Fall 20095DV0203 Outline Group communication Fault-tolerant services –Passive and active replication Highly.
Distributed Databases
Inexpensive Scalable Information Access Many Internet applications need to access data for millions of concurrent users Relational DBMS technology cannot.
MongoDB Sharding and its Threats
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation MongoDB Read Lecturer.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation MongoDB Write Lecturer.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation MongoDB Data Modeling.
Google Distributed System and Hadoop Lakshmi Thyagarajan.
ADVANCED MICROSOFT ACTIVE DIRECTORY CONCEPTS
Distributed Data Stores – Facebook Presented by Ben Gooding University of Arkansas – April 21, 2015.
1 The Google File System Reporter: You-Wei Zhang.
Software Engineer, #MongoDBDays.
Distributed Systems Tutorial 11 – Yahoo! PNUTS written by Alex Libov Based on OSCON 2011 presentation winter semester,
INSTALLING MICROSOFT EXCHANGE SERVER 2003 CLUSTERS AND FRONT-END AND BACK ‑ END SERVERS Chapter 4.
VLAN Trunking Protocol (VTP)
Chapter 8 Implementing Disaster Recovery and High Availability Hands-On Virtual Computing.
HBase A column-centered database 1. Overview An Apache project Influenced by Google’s BigTable Built on Hadoop ▫A distributed file system ▫Supports Map-Reduce.
Goodbye rows and tables, hello documents and collections.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation eXist Update Lecturer.
MongoDB Replica,Shard Cluster 中央大學電算中心 楊素秋
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation MongoDB Aggregation.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Amazon’s Dynamo Lecturer.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Trade-offs in Cloud.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation An Introduction to XML.
Content Addressable Network CAN. The CAN is essentially a distributed Internet-scale hash table that maps file names to their location in the network.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Data Versioning Lecturer.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Exam and Lecture Overview.
Grid Computing at Yahoo! Sameer Paranjpye Mahadev Konar Yahoo!
MapReduce and GFS. Introduction r To understand Google’s file system let us look at the sort of processing that needs to be done r We will look at MapReduce.
The Replica Location Service The Globus Project™ And The DataGrid Project Copyright (c) 2002 University of Chicago and The University of Southern California.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Partitioning and Replication.
MongoDB is a database management system designed for web applications and internet infrastructure. The data model and persistence strategies are built.
Fast Crash Recovery in RAMCloud. Motivation The role of DRAM has been increasing – Facebook used 150TB of DRAM For 200TB of disk storage However, there.
Eduardo Gutarra Velez. Outline Distributed Filesystems Motivation Google Filesystem Architecture The Metadata Consistency Model File Mutation.
GFS. Google r Servers are a mix of commodity machines and machines specifically designed for Google m Not necessarily the fastest m Purchases are based.
Authors Brian F. Cooper, Raghu Ramakrishnan, Utkarsh Srivastava, Adam Silberstein, Philip Bohannon, Hans-Arno Jacobsen, Nick Puz, Daniel Weaver, Ramana.
Fault Tolerant Services
High Availability in DB2 Nishant Sinha
Department of Computing, School of Electrical Engineering and Computer Sciences, NUST - Islamabad KTH Applied Information Security Lab Secure Sharding.
Session 1 Module 1: Introduction to Data Integrity
NOSQL DATABASE Not Only SQL DATABASE
Hwajung Lee.  Improves reliability  Improves availability ( What good is a reliable system if it is not available?)  Replication must be transparent.
Senior Solutions Architect, MongoDB Inc. Massimo Brignoli #MongoDB Introduction to Sharding.
1 Information Retrieval and Use De-normalisation and Distributed database systems Geoff Leese September 2008, revised October 2009.
Distributed File System. Outline Basic Concepts Current project Hadoop Distributed File System Future work Reference.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Introduction to Cloud.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Cassandra Architecture.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Amazon’s Dynamo Lecturer.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Cloud Data Models Lecturer.
Plan for Final Lecture What you may expect to be asked in the Exam?
Cassandra The Fortune Teller
and Big Data Storage Systems
Integrating HA Legacy Products into OpenSAF based system
MongoDB Distributed Write and Read
Partitioning and Replication
Learning MongoDB ZhangGang
Lecturer : Dr. Pavle Mogin
Senior Solutions Architect, MongoDB Inc.
MongoDB Connection in Husky
CHAPTER 3 Architectures for Distributed Systems
NOSQL databases and Big Data Storage Systems
The Google File System Sanjay Ghemawat, Howard Gobioff and Shun-Tak Leung Google Presented by Jiamin Huang EECS 582 – W16.
Interpret the execution mode of SQL query in F1 Query paper
EEC 688/788 Secure and Dependable Computing
THE GOOGLE FILE SYSTEM.
Distributed Availability Groups
The SMART Way to Migrate Replicated Stateful Services
Presentation transcript:

VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation MongoDB Architecture Lecturer : Dr. Pavle Mogin

Advanced Database Design and Implementation 2015 MongoDB_Architecture 1 Plan for MongoDB Sharding –Shard Key, –Sharding Architecture, –Balancing Data Distribution Replication –Master-Slave mode –Replica Set Operation –Failover - Election of a new Master –Reedings: Have a look at Readings on the Home Page

Advanced Database Design and Implementation 2015 MongoDB_Architecture 2 Shard Key Sharding partitions a collection’s data by the shard key A shard key is: –A single or more fields that exist in each document of a collection, –It is desirable that a shard key has unique values, or at least very large range of values, –The shard key has to be indexed, –A field containing an array cannot be a shard key, or a part of a shard key A shard key has to be defined within the command enabling sharding for a database collection Shard keys are immutable and cannot be changed after insertion All sharded collections must have an index that starts with the shard key (shard key is a prefix)

Advanced Database Design and Implementation 2015 MongoDB_Architecture 3 Chunks of the Shard Key Values MongoDB divides the shard key value range into chunks (subranges of the value range) and distributes the chunks evenly across the shards Each document of a collection is stored in a chunk according to its sharding key value Dividing shard key values into chunks is done either by: –Range based partitioning, or –Hash based partitioning There also exists a tag aware partitioning, where: –Certain key value subranges are tagged, –Tags are assigned to particular shards, –Shard keys belonging to a tagged subrange go to the corresponding shard

Advanced Database Design and Implementation 2015 MongoDB_Architecture 4 Sharding Range of values of the Shard Key min max chunk 1 chunk 2chunk 3chunk n... Shard 1 Shard m chunk 1chunk 5 chunk 10 chunk 3 chunk k

Advanced Database Design and Implementation 2015 MongoDB_Architecture 5 Range Based and Hash Based Sharding Range based sharding: –The space of shard key values is divided into non overlapping chuks –Each chunk is stored on a shard cluster –Documents having close shard key values are likely to be stored on the same shard –Favours range queries by shard key –May result in an uneven distribution of data and the work load Hash based sharding: –The space of hashes of shard key values is divided into non overlapping chuks – Documents having close shard key values are likely to be stored on different shards –Favours an even distribution of data and the work load –Inefficient range queries

Advanced Database Design and Implementation 2015 MongoDB_Architecture 6 Sharding Architecture Router (mongos) Application Server Router (mongos) Shard (replica set) Shard (replica set) Config Server 2 or more Routers 2 or more Shards Reads and Writes Driver

Advanced Database Design and Implementation 2015 MongoDB_Architecture 7 Comments on Sharding Architecture MongoDB supports sharding through the configuration of sharded clusters –A sharded cluster consists of: Three config processes, One or more shards (replica sets), and One or more mongos routing processes –Query routers or mongos instances interface with client applications via drivers, direct operations to the appropriate shards, and return results to clients –Config servers store the cluster’s metadata containing a mapping of the cluster’s data set to shards –The query routers use the metadata from config servers to target operations to specific shards –A driver is a client library for interacting with MongoDB in a particular language

Advanced Database Design and Implementation 2015 MongoDB_Architecture 8 Ballnced Data Distribution The addition of new data or servers can result in data distribution imbalances –A shard can contain significantly more chunks than another, or –Size of a chunk may become significantly greater then another MongoDB uses two background processes to keep a cluster balanced: –Splitting and –Ballncer

Advanced Database Design and Implementation 2015 MongoDB_Architecture 9 Splitting When a chunk grows beyond a specified size, MongoDB: –Splits the chunk into two halves, –Does not migrate any data (the shard contains more chunks now) Chunk (64.2 MB) Chunk (32.1 MB) Chunk (32.1 MB) Split Shard

Advanced Database Design and Implementation 2015 MongoDB_Architecture 10 Balancing When the distribution of chunks in a sharded collection becomes uneven in a cluster, a balancer that runs in all routers: –Migrates whole chunks from the shard with the largest number of chunks to the shard with the least number of chunks, –The origin shard keeps the chunk and answers queries until the chunk has been successfully transferred to the destination shard –Only then, MongoDB: Updates the meta data on config servers appropriately, and Deletes the chunk from the origin shard Shard A Shard B Chunk Migration

Advanced Database Design and Implementation 2015 MongoDB_Architecture 11 Adding and Removing Shards When a new shard joins a cluster it creates imbalance, since the new shard has no chunks –A balancer starts migrating data immediately When a shard needs to be removed from a cluster –A balancer migrates all of its chunks to other shards, –Updates the meta data on config servers appropriately, and –Only then, the shard can be removed

Advanced Database Design and Implementation 2015 MongoDB_Architecture 12 Replication In MongoDB, replication is implemented on the level of a shard A replica set contains replicas of a shard –A replica set is a cluster of MongoDB servers –There is a primary daemon process called mongod running on each server, –mongod handles data requests, manages data format, and performs background management operations Comment on the term daemon: –In multitasking programming systems, a daemon ] is a program that runs as a background process, rather than being under the direct control of an interactive user ] –Traditionally daemon names end with the letter d

Advanced Database Design and Implementation 2015 MongoDB_Architecture 13 Master and Slaves One mongod – the primary (or master): –Accepts all write request from clients, –Updates its data set, and –Records update operations in its operation log All other servers of the replica set – secondaries (or slaves): –Receive operations from the primary’s oplog, and –Apply them on their data sets If clients read from the primary, the replica set provides a strict consistency If clients are allowed to read from secondaries, the replica set provides an eventual consistency

Advanced Database Design and Implementation 2015 MongoDB_Architecture 14 Replica Set Operations Client Application Primary Writes Reads Secondary Replication Heartbeat

Advanced Database Design and Implementation 2015 MongoDB_Architecture 15 Failover Replica set members send heartbeats (pings) to each other every two seconds If a heartbeat does not return within 10 seconds, the other members mark the not responding node inaccessible –If a secondary becomes inaccessible, the replica set can continue to function without it (providing that there are enough live servers left), –If the primary becomes inaccessible, the remaining members of the replica set have to elect a new primary by voting (if the voting quorum is still available), –The replica set can not accept any write request if there is no primary, –The first secondary that gets majority of votes becomes a new primary and the replica set resumes the normal mode of operation Secondary having best performance, fastest response, least failure rate is promoted to a primary

Advanced Database Design and Implementation 2015 MongoDB_Architecture 16 Election Primary Secondary Heartbeat Election of a New Primary Primary Secondary Heartbeat New Primary Elected Replication

Advanced Database Design and Implementation 2015 MongoDB_Architecture 17 More on Election Fault tolerance for a replica set is the number of members that can become unavailable and still leave enough members in the set to elect a primary In a three members replica set, if two members are unavailable, the remaining one remains, or becomes the secondary disregarding what role it had before No of MembersElection MajorityFault Tolerance

Advanced Database Design and Implementation 2015 MongoDB_Architecture 18 Summary Data partitioning: –Sharding (horizontal partitioning) by a shard key, contained in all documents of a collection Data replication: –Performed on the level of a shard on the master-slave approach –Master is an instance of MongoDB that performs all writes and propagates them to slaves –If all reads also go to master – strict consistency, –Otherwise – eventual consistency –Master is a single point of failure –If master fails, a slave is elected as a new master A sharded cluster consists of: Three config processes, One or more shards (replica sets), and One or more mongos routing processes No data versioning