Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications C. Faloutsos – A. Pavlo How to Scale a Database System."— Presentation transcript:

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

2 CMU SCS hag·i·og·r a·phy (noun )

3 CMU SCS ChristosTheGreekGodofDatabases.com Pinterest meets Causal Encounters meets Kickstarter meets Twitter –With Christos!

4 CMU SCS More reads than writes. All media stored outside of DBMS. How do we choose the right database architecture? ChristosTheGreekGodofDatabases.com Faloutsos/PavloCMU SCS 15-415/6154

5 CMU SCS Outline Single-Node Databases NoSQL Systems NewSQL Systems Faloutsos/PavloCMU SCS 15-415/6155

6 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/PavloCMU SCS 15-415/6156

7 CMU SCS Mid-2000s MySQL + InnoDB is widely adopted by new web companies: –Supported transactions, replication, recovery. –Memcache for caching queries. Faloutsos/PavloCMU SCS 15-415/6157

8 CMU SCS 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? ChristosTheGreekGodofDatabases.com Faloutsos/PavloCMU SCS 15-415/6158

9 CMU SCS Buy a faster machine. Idea #1:

10 CMU SCS Scaling Up Application ServerDatabase Server (+) Requires no change to application. (+) Improvements are immediate. (-) Expensive! Diminishing Returns. (-) Single Point of Failure.  More disks.  More RAM.  Faster CPUs.  Use SSDs. Faloutsos/PavloCMU SCS 15-415/61510

11 CMU SCS Replicate database on multiple servers. Idea #2:

12 CMU SCS Replication Application ServerDatabase Server (+) Requires no change to application. (+) Parallelize read operations. (+) Improved fault tolerance. (-) Expensive! Diminishing Returns. (-) Writes limited to slowest node. Replicas Faloutsos/PavloCMU SCS 15-415/61512 Read Request

13 CMU SCS Cache query results. Idea #3:

14 CMU SCS Query Cache Application ServerDatabase Server (+) Reduce load on DBMS. (+) Fast API. (-) Extra roundtrip per query. (-) Requires application changes. (-) Doesn’t help write-heavy apps. Replicas Faloutsos/PavloCMU SCS 15-415/61514 Check Cache Query Request Update Cache memcache

15 CMU SCS Push SQL into stored procedures. Idea #4:

16 CMU SCS Stored Procedures Application Code Database Server (+) Reduces network roundtrips. (+) Less lock contention. (+) Modularization. (-) Application logic in two places. (-) PL/SQL is not standardized. Replicas def getPage(request): # Process request EXEC SQL # Process results if x == True: EXEC SQL else: EXEC SQL # Render HTML page return (html) def getPage(request): # Process request EXEC SQL # Process results if x == True: EXEC SQL else: EXEC SQL # Render HTML page return (html) BEGIN: EXEC SQL if x == True: EXEC SQL else: EXEC SQL return (results) END; BEGIN: EXEC SQL if x == True: EXEC SQL else: EXEC SQL return (results) END; def getPage(request): # Process request EXEC PROCEDURE # Render HTML page return (html) def getPage(request): # Process request EXEC PROCEDURE # Render HTML page return (html) Stored Procedure Faloutsos/PavloCMU SCS 15-415/61516

17 CMU SCS Shard database across multiple servers. Idea #5:

18 CMU SCS Sharding / Partitioning Application ServerDatabase Cluster (+) Parallelize all operations. (+) Much easier to add more hardware. (-) Most DBMSs don’t support this. (-) Joins are expensive. (-) Non-trivial to split database. Logical Partitions Faloutsos/PavloCMU SCS 15-415/61518

19 CMU SCS We want to scale out but writing a sharding layer is hard. Some parts of our application don’t need a full-featured DBMS. ChristosTheGreekGodofDatabases.com Faloutsos/PavloCMU SCS 15-415/615

20 CMU SCS Give up ACID guarantees for scalability. Idea #6:

21 CMU SCS Application Servers DBMS Servers Eventual Consistency Faloutsos/PavloCMU SCS 15-415/61521 Master Replicas Update Profile Get Profile ? ?

22 CMU SCS Late-2000s (NoSQL) NoSQL systems are able to scale horizontally right out of the box by giving traditional database features. Faloutsos/PavloCMU SCS 15-415/61522

23 CMU SCS We need to process payments. We don’t want to lose orders. We need joins and ACID transactions. ChristosTheGreekGodofDatabases.com

24 CMU SCS Strong Consistency Send Money Nice Christos Pictures! Thanks! -$100 +$100 Faloutsos/PavloCMU SCS 15-415/61524 Use Two- Phase Commit

25 CMU SCS Keep guarantees, optimize for workload type. Idea #7:

26 CMU SCS Early-2010s (NewSQL) New DBMSs that can scale across multiple machines natively and provide ACID guarantees.

27 CMU SCS Conclusion RDBMS (Single-Node): –MySQL, Postgres NoSQL (Multi-Node): –Key-Value, Documents, Graphs NewSQL (Multi-Node): –Transaction Processing, MySQL Sharding Faloutsos/PavloCMU SCS 15-415/61527

28 CMU SCS What DBMS should my start-up use?

29

30

31 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.


Download ppt "CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications C. Faloutsos – A. Pavlo How to Scale a Database System."

Similar presentations


Ads by Google