Distributed Databases and NOSQL

Distributed Databases and NOSQL

4/24/17 Announcements (Mon., Apr. 24) • Homework #4 due today (Monday, April 24, 11:55 pm) Distributed Databases • Project • final report draft due today -- Monday, April 24, 11:59 pm and • code due on Wednesday -- April 26, 11:59 pm • See all announcements about project report and demo on piazza NOSQL • Please bring a computer to class on Wednesday • We will take a 5-10 mins break for filling out course evaluations as Introduction to Databases advised by the Office of Assesments • Google Cloud code CompSci 316 Spring 2017 • Please redeem your code asap, by May 11 • Final Exam • May 2 (next Tuesday), 2-5 pm, in class • Everything covered in the class (up to last lecture) is included • If you need special accommodation, please email me Announcements (Mon., Apr. 24) Where are we now? We learnt ü XML ü Relational Model, Query ü DTD and XML schema • Final Project Report Languages, and Database ü XPath and XQuery • should be “comprehensive” Design ü Relational Mapping ü SQL • if you had more material in MS1 or MS2, please include them ü Advanced/Research topics ü RA overview • ü E/R diagram not the “work in progress” part ü ü Normalization Parallel DBMS ü Map Reduce ü DBMS Internals ü Data Mining • ü Storage The “overview of your application” part should include ü Indexing ü Data Warehousing • description of the user interface of your system – screenshots, ü Query Evaluation features, how the user will be able to interact with the system ü External sort • Today ü Join Algorithms – Distributed DBMS • Sample execution (input and output) ü Query Optimization – NOSQL • Your approach (algorithm, indexes, storage, optimization, üTransactions normalization) ü Basic concepts • Next lecture • Any interesting observation ü Concurrency control – Overview of other areas database ü Recovery researchers work on – Practice problems for the final Parallel vs. Distributed DBMS Parallel DBMS Distributed DBMS • Parallelization of various • Data is physically stored across operations different sites Distributed Databases • e.g. loading data, building – Each site is typically managed by indexes, evaluating an independent DBMS queries • Location of data and autonomy of • Data may or may not be sites have an impact on Query distributed initially opt., Conc. Control and recovery Architecture Data Storage • Distribution is governed • Also governed by other factors: Query Execution by performance – increased availability for system Transactions consideration crash – local ownership and access 1 4/24/17 Two desired properties and recent trends Distributed DBMS Architecture • Data is stored at several sites, each managed by a DBMS that can run independently • Three alternative approaches 1. Distributed Data Independence 1. Client-Server • Users should not have to know where data is located • One or more client (e.g. personal computer) and one or more 2. Distributed Transaction Atomicity server processes (e.g. a mainframe) • Users should be able to write transactions accessing multiple sites just • Clients are responsible for user interfaces, Server manages like local transactions data and executes queries • These two properties are in general desirable, but not always efficiently 2. Collaborating Server achievable • Queries can be submitted and can span multiple sites • e.g. when sites are connected by a slow long-distance network • No distinction between clients and servers • Even sometimes not desirable for globally distributed sites 3. Middleware • too much administrative overhead of making location of data • need just one db server (called middleware) capable of transparent (not visible to the user) managing queries and transactions spanning multiple servers • Therefore not always supported • the remaining servers can handle only the local queries and • Users have to be aware of where data is located transactions • can integrate legacy systems with limited flexibility and power Storing Data in a Distributed DBMS Fragmentation • Break a relation into smaller relations or fragments – store them in different sites as needed • Relations are stored across several sites TID t1 • Accessing data at a remote site incurs message- t2 passing costs t3 • To reduce this overhead, a single relation may be • Horizontal: t4 • Usually disjoint partitioned or fragmented across several sites • Can often be identified by a selection query (employees in a city – locality of reference) • typically at sites where they are most often accessed • To retrieve the full relation, need a union • The data can be replicated as well • Vertical: • when the relation is in high demand • Identified by projection queries • Typically unique TIDs added to each tuple • TIDs replicated in each fragments • Ensures that we have a Lossless Join (check yourself revisiting lossless join!) Distributed Query Processing: SELECT AVG(S.age) Non-Join Distributed Queries FROM Sailors S Replication WHERE S.rating > 3 AND S.rating < 7 • When we store several copies of a relation or relation tid sid sname rating age fragments T1 4 stored at Shanghai • can be replicated at one or more sites T2 5 • e.g. R is fragmented into R1, R2, R3; one copy of R2, R3; but two stored at Tokyo copies at R1 at two sites T3 9 • Advantages • Horizontally Fragmented: Tuples with rating < 5 at Shanghai, >= 5 at Tokyo. • Gives increased availability – e.g. when a site or communication link goes down • Must compute SUM(age), COUNT(age) at both sites. • Faster query evaluation – e.g. using a local copy • If WHERE contained just S.rating > 6, just one site • Synchronous and Asynchronous (later) • Vertically Fragmented: sid and rating at Shanghai, sname and age at Tokyo, • Vary in how current different copies are when a relation is modified tid at both. • Must reconstruct relation by join on tid, then evaluate the query SITE B SITE A • if no tid, decomposition would be lossy R1 R3 • Replicated: Sailors copies at both sites. R1 R2 • Choice of site based on local costs (e.g. index), shipping costs 2 4/24/17 Joins in a Distributed DBMS Semijoin -1/2 • Can be very expensive if relations are stored at • Suppose want to ship R to London and then do join with S at different sites London. Instead, 1. At London, project S onto join columns and ship this to Paris • Semi-join (we will cover only this) • Here foreign keys, but could be arbitrary join • Other join methods: 2. At Paris, join S-projection with R • Fetch as needed • Result is called reduction of Reserves w.r.t. Sailors (only these tuples are • Ship to one site needed) • Bloom join (similar approach to semi-join but uses hashing ) 3. Ship reduction of R to back to London 4. At London, join S with reduction of R LONDON PARIS LONDON PARIS Sailors (S) Reserves (R) Sailors (S) Reserves (R) 500 pages 1000 pages 500 pages 1000 pages Semijoin – 2/2 Updating Distributed Data • Synchronous Replication: • Tradeoff the cost of computing and shipping • All copies of a modified relation (or fragment) must be updated before projection for cost of shipping full R relation the modifying transaction commits • Data distribution is made totally “transparent” (not visible!) to users • Especially useful if there is a selection on Sailors, and • Before an update transaction can commit, it must obtain locks on all answer desired at London modified copies – Slow! • By Majority voting or “read any write all” • Asynchronous Replication: • Copies of a modified relation are only periodically updated; different copies may get out of sync in the meantime LONDON PARIS • Users must be aware of data distribution Sailors (S) Reserves (R) • More efficient – many current products follow this approach • Update “master” copy and propagate (primary site), or update “any” copy and propagate (peer to peer) 500 pages 1000 pages Distributed Transactions Distributed Deadlock Detection • Distributed CC T1 T2 T1 T2 T1 T2 • How can locks for objects stored across several sites be SITE A SITE B GLOBAL managed? • How can deadlocks be detected in a distributed database? • Locking can happen: • Distributed Recovery • Centrally – one site manages all locks • Primary site – primary copy is locked • When a transaction commits, all its actions, across all the • Distributed – by different sites storing a copy sites at which is executes must persist • Each site maintains a local waits-for graph • When a transaction aborts, none of its actions must be allowed to persist • A global deadlock might exist even if the local graphs contain no cycles • Further, phantom deadlocks may be created while communicating • due to delay in propagating local information • might lead to unnecessary aborts 3 4/24/17 Three Distributed Deadlock Detection Approaches Distributed Recovery T1 T2 T1 T2 T1 T2 • Two new issues: SITE A SITE B GLOBAL • New kinds of failure, e.g., links and remote sites 1. Centralized • If “sub-transactions” of a transaction execute • send all local graphs to one site periodically at different sites, all or none must commit • A global waits-for graph is generated • Need a commit protocol to achieve this 2. Hierarchical • Most widely used: Two Phase Commit (2PC) • organize sites into a hierarchy and send local graphs to parent in the hierarchy • e.g. sites (every 10 sec)-> sites in a state (every min)-> sites in a • A log is maintained at each site country (every 10 min) -> global waits for graph • as in a centralized DBMS • intuition: more deadlocks are likely across closely related sites • commit protocol actions are additionally logged 3. Timeout • abort transaction if it waits too long (low overhead) Two-Phase Commit (2PC) NoSQL

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    8 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us