hag i og ra phy
play

hagiography (noun) CMU SCS ChristosTheGreekGodofDatabases.com - PDF document

Faloutsos/Pavlo CMU - 15-415/615 CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications C. Faloutsos A. Pavlo How to Scale a Database System CMU SCS hagiography (noun) CMU SCS


  1. Faloutsos/Pavlo CMU - 15-415/615 CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications C. Faloutsos – A. Pavlo How to Scale a Database System CMU SCS hag·i·og·ra·phy (noun) CMU SCS ChristosTheGreekGodofDatabases.com • Pinterest meets Causal Encounters meets Kickstarter meets Twitter – With Christos! 1

  2. Faloutsos/Pavlo CMU - 15-415/615 CMU SCS ChristosTheGreekGodofDatabases.com • More reads than writes. • All media stored outside of DBMS. • How do we choose the right database architecture? Faloutsos/Pavlo CMU SCS 15-415/615 4 CMU SCS Outline • Single-Node Databases • NoSQL Systems • NewSQL Systems Faloutsos/Pavlo CMU SCS 15-415/615 5 CMU SCS Late-1990s / Early-2000s • All the big players were heavyweight and expensive. – Oracle, DB2, Sybase, SQL Server, Informix. • Open-source databases were missing important features. – Postgres, mSQL, MySQL. Faloutsos/Pavlo CMU SCS 15-415/615 6 2

  3. Faloutsos/Pavlo CMU - 15-415/615 CMU SCS Mid-2000s • MySQL + InnoDB is widely adopted by new web companies: – Supported transactions, replication, recovery. – Memcache for caching queries. Faloutsos/Pavlo CMU SCS 15-415/615 7 CMU SCS ChristosTheGreekGodofDatabases.com • Let’s go with MySQL. • We’re getting a lot of traffic. • Our database server is saturated! How do we increase the capacity of our database server? Faloutsos/Pavlo CMU SCS 15-415/615 8 CMU SCS Idea #1: Buy a faster machine. 3

  4. Faloutsos/Pavlo CMU - 15-415/615 CMU SCS Scaling Up  More disks.  More RAM.  Faster CPUs.  Use SSDs. Application Server Database Server (+) Requires no change to application. (-) Expensive! Diminishing Returns. (+) Improvements are immediate. (-) Single Point of Failure. Faloutsos/Pavlo CMU SCS 15-415/615 10 CMU SCS Idea #2: Replicate database on multiple servers. CMU SCS Replication Read Request Application Server Database Server Replicas (+) Requires no change to application. (-) Expensive! Diminishing Returns. (+) Parallelize read operations. (-) Writes limited to slowest node. (+) Improved fault tolerance. Faloutsos/Pavlo CMU SCS 15-415/615 12 4

  5. Faloutsos/Pavlo CMU - 15-415/615 CMU SCS Idea #3: Cache query results. CMU SCS Query Cache Update Cache memcache Check Cache Query Request Application Server Database Server Replicas (+) Reduce load on DBMS. (-) Extra roundtrip per query. (+) Fast API. (-) Requires application changes. (- ) Doesn’t help write -heavy apps. Faloutsos/Pavlo CMU SCS 15-415/615 14 CMU SCS Idea #4: Push SQL into stored procedures. 5

  6. Faloutsos/Pavlo CMU - 15-415/615 CMU SCS Stored Procedures Stored Procedure def getPage(request): BEGIN : EXEC SQL # Process request EXEC SQL EXEC SQL if x == True: def getPage(request): EXEC SQL EXEC SQL else: # Process request # Process results EXEC SQL EXEC PROCEDURE return (results) if x == True: END; # Render HTML page EXEC SQL return (html) else: EXEC SQL # Render HTML page Database Server return (html) Replicas Application Code (+) Reduces network roundtrips. (-) Application logic in two places. (+) Less lock contention. (-) PL/SQL is not standardized. (+) Modularization. Faloutsos/Pavlo CMU SCS 15-415/615 16 CMU SCS Idea #5: Shard database across multiple servers. CMU SCS Sharding / Partitioning Logical Partitions Application Server Database Cluster (+) Parallelize all operations. (- ) Most DBMSs don’t support this. (+) Much easier to add more hardware. (-) Joins are expensive. (-) Non-trivial to split database. Faloutsos/Pavlo CMU SCS 15-415/615 18 6

  7. Faloutsos/Pavlo CMU - 15-415/615 CMU SCS ChristosTheGreekGodofDatabases.com • We want to scale out but writing a sharding layer is hard. • Some parts of our application don’t need a full-featured DBMS. Faloutsos/Pavlo CMU SCS 15-415/615 CMU SCS Idea #6: Give up ACID guarantees for scalability. CMU SCS Eventual Consistency Application Servers Update Profile ? DBMS Servers ? Master Replicas Get Profile Faloutsos/Pavlo CMU SCS 15-415/615 21 7

  8. Faloutsos/Pavlo CMU - 15-415/615 CMU SCS Late-2000s (NoSQL) • NoSQL systems are able to scale horizontally right out of the box by giving traditional database features. Faloutsos/Pavlo CMU SCS 15-415/615 22 CMU SCS ChristosTheGreekGodofDatabases.com • We need to process payments. • We don’t want to lose orders. • We need joins and ACID transactions. CMU SCS Strong Consistency Use Two- Phase Commit Nice Christos Pictures! -$100 Send Money +$100 Thanks! Faloutsos/Pavlo CMU SCS 15-415/615 24 8

  9. Faloutsos/Pavlo CMU - 15-415/615 CMU SCS Idea #7: Keep guarantees, optimize for workload type. CMU SCS Early-2010s (NewSQL) • New DBMSs that can scale across multiple machines natively and provide ACID guarantees. CMU SCS Conclusion • RDBMS (Single-Node): – MySQL, Postgres • NoSQL (Multi-Node): – Key-Value, Documents, Graphs • NewSQL (Multi-Node): – Transaction Processing, MySQL Sharding Faloutsos/Pavlo CMU SCS 15-415/615 27 9

  10. Faloutsos/Pavlo CMU - 15-415/615 CMU SCS What DBMS should my start-up use? 10

  11. Faloutsos/Pavlo CMU - 15-415/615 CMU SCS Beyond the 15-415/615 • Christos is teaching 15-826 this fall: – Multimedia Databases and Data Mining • Send me an email if you’re interested in working on a database research project. 11

Recommend


More recommend