1 / 73

Database Replication in Tashkent

Database Replication in Tashkent. CSEP 545 Transaction Processing Sameh Elnikety. Replication for Performance. Expensive Limited scalability. DB Replication is Challenging. Single database system Large, persistent state Transactions Complex software Replication challenges

dot
Télécharger la présentation

Database Replication in Tashkent

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. Database Replication in Tashkent CSEP 545 Transaction Processing Sameh Elnikety

  2. Replication for Performance Expensive Limited scalability

  3. DB Replication is Challenging • Single database system • Large, persistent state • Transactions • Complex software • Replication challenges • Maintain consistency • Middleware replication

  4. Background Standalone DBMS Replica 1

  5. Background Replica 1 Load Balancer Replica 2 Replica 3

  6. Read Tx Read tx does not change DB state Replica 1 Load Balancer Replica 2 T Replica 3

  7. Update Tx 1/2 Update txchanges DB state Replica 1 Load Balancer Replica 2 T ws ws Replica 3

  8. Update Tx 1/2 Update txchanges DB state Apply (or commit) T everywhere Replica 1 ws Load Balancer Replica 2 T ws ws ws Replica 3 Example: T1: { set x = 1 } ws

  9. Update Tx 2/2 Update txchanges DB state Replica 1 Ordering Load Balancer Replica 2 T T ws ws Replica 3 ws ws

  10. Update Tx 2/2 Update txchanges DB state Commit updates in order Replica 1 ws ws Ordering Load Balancer Replica 2 ws T ws ws ws Replica 3 Replica 3 Example: T1: { set x = 1 }T2: { set x = 7 } ws T ws

  11. Sub-linear Scalability Wall Replica 1 ws ws Ordering Load Balancer Replica 2 ws T ws ws ws Replica 3 Replica 3 Replica 4 ws T ws

  12. This Talk • General scaling techniques • Address fundamental bottlenecks • Synergistic, implemented in middleware • Evaluated experimentally

  13. Super-linear Scalability 37 X 25 X TPS 12 X 7 X 1 X

  14. Big Picture: Let’s Oversimplify Standalone DBMS reading R update U logging

  15. Big Picture: Let’s Oversimplify Standalone DBMS reading R update U logging R Replica 1/N (traditional) reading N.R U update (N-1).ws N.U logging

  16. Big Picture: Let’s Oversimplify Standalone DBMS reading R update U logging R Replica 1/N (traditional) reading N.R U update (N-1).ws N.U logging R* Replica 1/N (optimized) reading N.R U* update (N-1).ws* N.U logging

  17. Big Picture: Let’s Oversimplify Standalone DBMS reading R update U logging R Replica 1/N (traditional) reading N.R U update (N-1).ws N.U logging R* Replica 1/N (optimized) reading MALB Update Filtering Uniting O & D N.R U* update (N-1).ws* N.U logging

  18. Key Points • Commit updates in order • Perform serial synchronous disk writes • Unite ordering and durability • Load balancing • Optimize for equal load: memory contention • MALB: optimize for in-memory execution • Update propagation • Propagate updates everywhere • Update filtering: propagate to where needed

  19. Roadmap 2, 3 1 Tx A Replica 1 Ordering Load Balancer Replica 2 Replica 3 Commit updates in order Load balancing Update propagation

  20. Key Idea • Traditionally: • Commit ordering and durability are separated • Key idea: • Unite commit ordering and durability

  21. All Replicas Must Agree Replica 1 Tx A • All replicas agree on • which update tx commit • their commit order • Total order • Determined by middleware • Followed by each replica durability Replica 2 Tx B durability Replica 3 durability

  22. Order Outside DBMS Replica 1 Tx A Tx A durability Tx B Ordering Replica 2 Tx B durability Replica 3 durability

  23. Order Outside DBMS Replica 1 Tx A Tx A durability A  B A  B Tx B Ordering Replica 2 Tx B durability A  B A  B A  B Replica 3 A  B durability A  B

  24. DBMS Proxy Task A SQL interface Task B Tx A Tx B Enforce External Commit Order Ordering A  B Replica 3 durability

  25. DBMS Proxy Task A SQL interface Task B Tx A Tx B  A Enforce External Commit Order Ordering A  B Replica 3 durability B

  26. DBMS Proxy Task A SQL interface Task B Tx A Tx B  A Enforce External Commit Order Ordering A  B Replica 3 durability B Cannot commit A & B concurrently!

  27. Proxy Task A SQL interface Task B Tx A Tx B Enforce Order = Serial Commit Ordering A  B Replica 3 DBMS durability A

  28. Proxy Task A SQL interface Task B Tx A Tx B  B Enforce Order = Serial Commit Ordering A  B Replica 3 DBMS durability A

  29. Commit Serialization is Slow Ordering A B C Commit orderA B C Proxy Ack B Ack A Ack C DBMS Commit A Commit B Commit C CPU DurabilityA CPU DurabilityA  B CPU DurabilityA B  C durability

  30. Commit Serialization is Slow Ordering A B C Commit orderA B C Proxy Ack B Ack A Ack C Problem: Durability & ordering separated →serial disk writes DBMS Commit A Commit B Commit C CPU DurabilityA CPU DurabilityA  B CPU DurabilityA B  C durability

  31. Unite D. & O. in Middleware Ordering A B C DurabilityA B  C Commit orderA B C durability Proxy Ack B Ack A Ack C DBMS Commit A Commit B Commit C CPU CPU CPU durability OFF

  32. Unite D. & O. in Middleware Ordering A B C DurabilityA B  C Commit orderA B C durability Proxy Ack B Ack A Ack C Solution: Move durability to MW Durability & ordering in middleware →group commit DBMS Commit A Commit B Commit C CPU CPU CPU durability OFF

  33. Implementation: Uniting D & O in MW • Middleware logs tx effects • Durability of update tx • Guaranteed in middleware • Turn durability off at database • Middleware performs durability & ordering • United → group commit → fast • Database commits update tx serially • Commit = quick main memory operation

  34. Uniting Improves Throughput • Metric • Throughput • Workload • TPC-W Ordering • (50% updates) • System • Linux cluster • PostgreSQL • 16 replicas • Serializable exec. 12 X 7 X TPS 1 X TPC-W

  35. Roadmap 2, 3 1 Tx A Replica 1 Ordering Load Balancer Replica 2 Replica 3 Commit updates in order Load balancing Update propagation

  36. Key Idea Replica 1 Equal load on replicas Mem Disk Load Balancer Replica 2 Mem Disk

  37. Key Idea Replica 1 Equal load on replicas Mem Disk Load Balancer Replica 2 Mem MALB: (Memory-Aware Load Balancing)Optimize for in-memory execution Disk

  38. How Does MALB Work? 1 2 3 Database 1 2 Workload A → B → 2 3 Mem Memory

  39. Read Data From Disk Replica 1 A → B → 1 2 A, B, A, B Mem 2 3 Disk A, B, A, B Least Loaded 1 1 2 3 3 Replica 2 Mem Disk A, B, A, B 1 2 3

  40. Read Data From Disk Replica 1 A → B → 1 2 A, B, A, B Mem 2 3 1 1 2 3 3 Slow Disk A, B, A, B Least Loaded 1 1 2 3 3 Replica 2 Mem Slow 1 1 2 3 3 Disk A, B, A, B 1 2 3

  41. Data Fits in Memory Replica 1 A → B → 1 2 A, A, A, A Mem 2 3 Disk A, B, A, B MALB 1 2 3 Replica 2 Mem Disk B, B, B, B 1 2 3

  42. Data Fits in Memory Replica 1 A → B → 1 2 A, A, A, A Mem 2 3 1 2 Fast Disk A, B, A, B MALB 1 2 3 Replica 2 Mem Fast 2 3 Memory info? Many tx and replicas? Disk B, B, B, B 1 2 3

  43. Estimate Tx Memory Needs • Exploit tx execution plan • Which tables & indices are accessed • Their access pattern • Linear scan, direct access • Metadata from database • Sizes of tables and indices

  44. Grouping Transactions • Objective • Construct tx groups that fit together in memory • Bin packing • Item:tx memory needs • Bin: memory of replica • Heuristic: Best Fit Decreasing • Allocate replicas to tx groups • Adjust for group loads

  45. MALB in Action A B CD E F MALB

  46. MALB in Action Memory needs for A, B, C, D, E, F A B CD E F MALB

  47. MALB in Action Group A Memory needs for A, B, C, D, E, F A B CD E F MALB Group B C Group D E F

  48. MALB in Action Replica Group A Memory needs for A, B, C, D, E, F A Disk A B CD E F MALB Replica Group B C B C Disk Group D E F Replica D E F Disk

  49. MALB Summary • Objective • Optimize for in-memory execution • Method • Estimate tx memory needs • Construct tx groups • Allocate replicas to tx groups

  50. Experimental Evaluation • Implementation • No change in consistency • Still middleware • Compare • United: efficient baseline system • MALB: exploits working set information • Same environment • Linux cluster running PostgreSQL • Workload: TPC-W Ordering (50% update txs)

More Related