1 / 55

Parallel Databases

Parallel Databases. COMP3017 Advanced Databases. Dr Nicholas Gibbins - nmg @ecs.soton.ac.uk 2012-2013. Definitions. Parallelism An arrangement or state that permits several operations or tasks to be performed simultaneously rather than consecutively Parallel Databases

atalo
Download Presentation

Parallel Databases

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Parallel Databases COMP3017 Advanced Databases Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk2012-2013

  2. Definitions Parallelism • An arrangement or state that permits several operations or tasks to be performed simultaneously rather than consecutively Parallel Databases • have the ability to split • processing of data • access to data • across multiple processors

  3. Why Parallel Databases • Hardware trends • Reduced elapsed time for queries • Increased transaction throughput • Increased scalability • Better price/performance • Improved application availability • Access to more data • In short, for better performance

  4. Shared Memory Architecture • Tightly coupled • Symmetric Multiprocessor (SMP) P = processor M = memory P P P Global Memory

  5. Software – Shared Memory • Less complex database software • Limited scalability • Single buffer • Single database storage P P P Global Memory

  6. Shared Disc Architecture • Loosely coupled • Distributed Memory P P P M M M S

  7. Software – Shared Disc • Avoids memory bottleneck • Same page may be in more than one buffer at once – can lead to incoherence • Needs global locking mechanism • Single logical database storage • Each processor has its own database buffer P P P M M M S

  8. Shared Nothing Architecture • Massively Parallel • Loosely Coupled • High Speed Interconnect (between processors) P P P M M M

  9. Software - Shared Nothing • One page is only in one local buffer – no buffer incoherence • Needs distributed deadlock detection • Needs multiphase commit protocol • Needs to break SQL requests into multiple sub-requests • Each processor has its own database buffer • Each processor owns part of the data P P P M M M

  10. Hardware vs. Software Architecture • It is possible to use one software strategy on a different hardware arrangement • Also possible to simulate one hardware configuration on another • Virtual Shared Disk (VSD) makes an IBM SP shared nothing system look like a shared disc setup (for Oracle) • From this point on, we deal only with shared nothing software mode

  11. Shared Nothing Challenges • Partitioning the data • Keeping the partitioned data balanced • Splitting up queries to get the work done • Avoiding distributed deadlock • Concurrency control • Dealing with node failure

  12. Hash Partitioning Table

  13. Range Partitioning A-H I-P Q-Z

  14. Schema Partitioning Table 1 Table 2

  15. Rebalancing Data Data in proper balance Data grows, performance drops Add new nodes and disc Redistribute data to new nodes

  16. Dividing up the Work Application Coordinator Process WorkerProcess WorkerProcess WorkerProcess

  17. DB Software on each node App1 App2 DBMS DBMS DBMS C1 C2 W1 W2 W1 W2 W1 W2

  18. Transaction Parallelism Improves throughput Inter-Transaction • Run many transactions in parallel, sharing the DB • Often referred to as Concurrency

  19. Query Parallelism Improves response times (lower latency) Intra-operator (horizontal) parallelism • Operators decomposed into independent operator instances, which perform the same operation on different subsets of data Inter-operator (vertical) parallelism • Operations are overlapped • Pipeline data from one stage to the next without materialisation

  20. Intra-Operator Parallelism SQL Query SubsetQueries SubsetQueries SubsetQueries SubsetQueries Processor Processor Processor Processor

  21. Intra-Operator Parallelism Example query: • SELECT c1,c2 FROM t1 WHERE c1>5.5 Assumptions: • 100,000 rows • Predicates eliminate 90% of the rows

  22. I/O Shipping Coordinatorand Worker 10,000 (c1,c2) Network Worker Worker Worker Worker 25,000 rows 25,000 rows 25,000 rows 25,000 rows

  23. Function Shipping Coordinator 10,000 (c1,c2) Network Worker Worker Worker Worker 2,500 rows 2,500 rows 2,500 rows 2,500 rows

  24. Function Shipping Benefits • Database operations are performed where the data are, as far as possible • Network traffic in minimised • For basic database operators, code developed for serial implementations can be reused • In practice, mixture of Function Shipping and I/O Shipping has to be employed

  25. Inter-Operator Parallelism Scan Join Sort Scan Join Sort time

  26. Resulting Parallelism Scan Join Sort Scan Join Sort Scan Scan Join Join Sort Sort time

  27. Basic Operators • The DBMS has a set of basic operations which it can perform • The result of each operation is another table • Scan a table – sequentially or selectively via an index – to produce another smaller table • Join two tables together • Sort a table • Perform aggregation functions (sum, average, count) • These are combined to execute a query

  28. The Volcano Architecture • The Volcano Query Processing System was devised by Goetze Graefe (Oregon) • Introduced the Exchange operator • Inserted between the steps of a query to: • Pipeline results • Direct streams of data to the next step(s), redistributing as necessary • Provides mechanism to support both vertical and horizontal parallelism • Informix ‘Dynamic Scalable Architecture’ based on Volcano

  29. Exchange Operators Example query: • SELECT county, SUM(order_item)FROM customer, orderWHERE order.customer_id=customer_idGROUP BY countyORDER BY SUM(order_item)

  30. Exchange Operators SORT GROUP HASHJOIN SCAN SCAN Customer Order

  31. Exchange Operators HASHJOIN HASHJOIN HASHJOIN EXCHANGE SCAN SCAN Customer

  32. Exchange Operators HASHJOIN HASHJOIN HASHJOIN EXCHANGE EXCHANGE SCAN SCAN SCAN SCAN SCAN Customer Order

  33. SORT EXCHANGE GROUP GROUP EXCHANGE HASHJOIN HASHJOIN HASHJOIN EXCHANGE EXCHANGE SCAN SCAN SCAN SCAN SCAN Customer Order

  34. Query Processing

  35. Some Parallel Queries • Enquiry • Collocated Join • Directed Join • Broadcast Join • Repartitioned Join

  36. Orders Database CUSTOMER CUSTKEY C_NAME … C_NATION … ORDER ORDERKEY DATE … CUSTKEY … SUPPKEY … SUPPLIER SUPPKEY S_NAME … S_NATION …

  37. Enquiry/Query “How many customers live in the UK?” Data from application Return to application COORDINATOR SUM Return subcounts to coordinator SCAN SLAVE TASKS COUNT Multiple partitionsof customer table

  38. Collocated Join “Which customers placed orders in July?” UNION Requires a JOIN of CUSTOMER and ORDER Tables both partitioned onCUSTKEY (the same key) andtherefore corresponding entriesare on the same node JOIN SCAN SCAN ORDER CUSTOMER

  39. Directed Join “Which customers placed orders in July?”(tables have different keys) Return to application Coordinator Slave Task 1 Slave Task 2 JOIN SCAN SCAN ORDER CUSTOMER ORDER partitioned on ORDERKEY, CUSTOMER partitioned on CUSTKEY Retrieve rows from ORDER, then use ORDER.CUSTKEY to direct appropriate rows to nodes with CUSTOMER

  40. Broadcast Join “Which customers and suppliers are in the same country?” Return to application Coordinator Slave Task 1 Slave Task 2 JOIN SCAN BROADCAST SCAN SUPPLIER CUSTOMER SUPPLIER partitioned on SUPPKEY, CUSTOMER on CUSTKEY. Join required on *_NATION Send all SUPPLIER to each CUSTOMER node

  41. Repartitioned Join “Which customers and suppliers are in the same country?” Coordinator Slave Task 3 JOIN Slave Task 1 Slave Task 2 SCAN SCAN SUPPLIER CUSTOMER SUPPLIER partitioned on SUPPKEY, CUSTOMER on CUSTKEY. Join required on *_NATION. Repartition both tables on *_NATION to localise and minimise the join effort

  42. Query Handling • Critical aspect of Parallel DBMS • User wants to issue simple SQL, and not be concerned with parallel aspects • DBMS needs structures and facilities to parallelise queries • Good optimiser technology is essential • As database grows, effects (good or bad) of optimiser become increasingly significant

  43. Further Aspects • A single transaction may update data in several different places • Multiple transactions may be using the same (distributed) tables simultaneously • One or several nodes could fail • Requires concurrency control and recovery across multiple nodes for: • Locking and deadlock detection • Two-phase commit to ensure ‘all or nothing’

  44. Deadlock Detection

  45. Locking and Deadlocks • With Shared Nothing architecture, each node is responsible for locking its own data • No global locking mechanism • However: • T1 locks item A on Node 1 and wants item B on Node 2 • T2 locks item B on Node 2 and wants item A on Node 1 • Distributed Deadlock

  46. Resolving Deadlocks • One approach – Timeouts • Timeout T2, after wait exceeds a certain interval • Interval may need random element to avoid ‘chatter’i.e. both transactions give up at the same time and then try again • Rollback T2 to let T1 to proceed • Restart T2, which can now complete

  47. Resolving Deadlocks • More sophisticated approach (DB2) • Each node maintains a local ‘wait-for’ graph • Distributed deadlock detector (DDD) runs at the catalogue node for each database • Periodically, all nodes send their graphs to the DDD • DDD records all locks found in wait state • Transaction becomes a candidate for termination if found in same lock wait state on two successive iterations

  48. Reliability

  49. Reliability We wish to preserve the ACID properties for parallelised transactions • Isolation is taken care of by 2PL protocol • Isolation implies Consistency • Durability can be taken care of node-by-node, with proper logging and recovery routines • Atomicity is the hard part. We need to commit all parts of a transaction, or abort all parts Two-phase commit protocol (2PC) is used to ensure that Atomicity is preserved

  50. Two-Phase Commit (2PC) Distinguish between: • The global transaction • The local transactions into which the global transaction is decomposed Global transaction is managed by a single site, known as the coordinator Local transactions may be executed on separate sites, known as the participants

More Related