high availability for database systems in cloud computing environments

54
High Availability for Database Systems in Cloud Computing Environments Ashraf Aboulnaga University of Waterloo

Upload: cais

Post on 23-Feb-2016

22 views

Category:

Documents


0 download

DESCRIPTION

High Availability for Database Systems in Cloud Computing Environments. Ashraf Aboulnaga University of Waterloo. Acknowledgments. University of Waterloo Prof. Kenneth Salem Umar Farooq Minhas Rui Liu (post-doctoral fellow) University of British Columbia Prof. Andrew Warfield - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: High Availability for Database Systems in Cloud Computing Environments

High Availability for Database Systems in Cloud Computing

EnvironmentsAshraf AboulnagaUniversity of Waterloo

Page 2: High Availability for Database Systems in Cloud Computing Environments

Acknowledgments University of Waterloo

Prof. Kenneth Salem Umar Farooq Minhas Rui Liu (post-doctoral fellow)

University of British Columbia Prof. Andrew Warfield Shriram Rajagopalan Brendan Cully

2

Page 3: High Availability for Database Systems in Cloud Computing Environments

What is Cloud Computing? Trend toward consolidation in server-side

computing Cloud computing: massive, shared, hosted

clusters of servers

3

Page 4: High Availability for Database Systems in Cloud Computing Environments

What is Cloud Computing?

4

Cloud provider makes available massive clusters of servers running applications that provide services to users

Users access the provided services through the internet or an intranet

Page 5: High Availability for Database Systems in Cloud Computing Environments

Why Cloud Computing? For cloud provider

Consolidation leads to economies of scale Cheaper hardware, software, networking, power Easier to invest in administration, availability, security, etc.

Enables extreme levels of scalability Makes it possible to support 100’s of millions of users or

requests, and terabytes of data For cloud user

Capital expenses for computing become operational expenses

Lower cost and higher quality of service Elasticity

Grow and shrink your computing resources as you need, and pay only for what you use

5

Page 6: High Availability for Database Systems in Cloud Computing Environments

Database Systems in the Cloud Using cloud technologies plus SQL database

systems to build a scalable highly available database service in the cloud

Better deployment of database systems in the cloud

Better support for database systems by cloud technologies

6

Page 7: High Availability for Database Systems in Cloud Computing Environments

Why Database Systems? Databases are important!

A narrow interface to the user (SQL)

Transactions offer well defined semantics for data access and update

Well defined internal structures (e.g., buffer pool) and query execution operators (e.g., hash joins)

Accurate performance models for query execution time and resource consumption

7

Page 8: High Availability for Database Systems in Cloud Computing Environments

Outline Introduction RemusDB: Database high availability using

virtualizationUmar Farooq Minhas, Shriram Rajagopalan, Brendan Cully, Ashraf Aboulnaga, Kenneth Salem, and Andrew Warfield. “RemusDB: Transparent High Availability for Database Systems,” In Proceedings of the VLDB Endowment (PVLDB), 2011.(Best Paper Award)

DBECS: Database high availability (and scalability) using eventually consistent cloud storage

Conclusion

8

Page 9: High Availability for Database Systems in Cloud Computing Environments

Virtual Machines

CPU CPU Mem NetPhysical Machine

CPU CPU Mem

Virtual Machine 1

CPU Mem Net

Virtual Machine 2

Operating System Operating System

Virtual Machine Monitor (VMM)

App 1 App 3App 2 App 4 App 5

Page 10: High Availability for Database Systems in Cloud Computing Environments

Capabilities of VMMs Strong isolation between VMs Controlling the allocation of resources (CPU,

memory, etc.) to VMs Pause, checkpoint, resume VMs Live VM migration between physical servers … and more

10

Page 11: High Availability for Database Systems in Cloud Computing Environments

High Availability A database system is highly available if it remains

accessible to its users in the face of hardware failures

High availability (HA) is becoming a requirement for almost all database applications, not just mission critical ones

Key issues: Maintaining database consistency in the face of failure Minimizing the impact on performance during normal

operation and after a failure Reducing the complexity and administrative overhead of HA

11

Page 12: High Availability for Database Systems in Cloud Computing Environments

Active/Standby Replication

A copy of the database is stored on two servers, a primary and a backup

Primary server (active) accepts user requests and performs database updates

Changes to database propagated to backup server (standby) by propagating the transaction log

Upon failure, backup server takes over as primary12

DB

DBMS

Primary Server

DB

DBMS

Backup Server

Database Changes(Transaction Log)

Primary Server

Page 13: High Availability for Database Systems in Cloud Computing Environments

Active/Standby Replication Active/standby replication is complex to implement in

the DBMS, and complex to administer Propagating the transaction log Atomic handover from primary to backup on failure Redirecting client requests to backup after failure Minimizing effect on performance (e.g., warming the buffer

pool of the backup) Our approach: Implement active/standby replication

at the virtual machine layer Push the complexity out of the DBMS High availability as a service: Any DBMS can be made

highly available with little or no code changes Low performance overhead

13

Page 14: High Availability for Database Systems in Cloud Computing Environments

Changes to VM State

Transparent HA for DBMS

RemusDB: efficient and transparent active/standby high availability for DBMS implemented in the virtualization layer

Propagates all changes in VM state from primary to backup High availability with no code changes to the DBMS Completely transparent failover from primary to backup Failover to a warmed up backup server

Backup Server

DB DBMS

Primary Server

VM

DBDBMS

VM

Primary Server

14

Page 15: High Availability for Database Systems in Cloud Computing Environments

Remus and VM Checkpointing RemusDB is based on Remus, a high availability solution

that is now part of the Xen virtual machine monitor

Remus maintains a replica of a running VM on a separate physical machine

Periodically replicates state changes from the primary VM to the backup VM using whole machine checkpointing

Checkpointing is based on extensions to live VM migration

Provides transparent failover with only seconds of downtime

15

Page 16: High Availability for Database Systems in Cloud Computing Environments

Remus Checkpoints Remus divides time into epochs (~25ms) Performs a checkpoint at the end of each epoch

1. Suspend primary VM2. Copy all state changes to a buffer in Domain 03. Resume primary VM4. Send asynchronous message to backup containing state changes5. Backup VM applies state changes

16

Periodic Checkpoints(Changes to VM State)

Primary Server

Domain 0

BackupServer

Domain 0

Xen VMM

PrimaryVM

Xen VMM

BackupVM

Page 17: High Availability for Database Systems in Cloud Computing Environments

Remus Checkpoints

After a failure, the backup resumes execution from the latest checkpoint

Any work done by the primary during epoch C will be lost (unsafe) Remus provides a consistent view of execution to clients

Any network packets sent during an epoch are buffered until the next checkpoint

Guarantees that a client will see results only if they are based on safe execution

Same principle is also applied to disk writes

17

Page 18: High Availability for Database Systems in Cloud Computing Environments

Remus and DB Workloads

DBMSClient

PrimaryServer

query response(unprotected)

no protectionprocessing

response time(unprotected)

Remus protectionnetworkbuffering

response(protected)

overhead ofprotection

up to 32 %

response time(protected)

RemusDB implements optimizations to reduce the overhead of protection for database workloads

Incurs 3% overhead and recovers from failures in 3 seconds

18

Page 19: High Availability for Database Systems in Cloud Computing Environments

RemusDB Remus optimized for protecting database workloads Memory optimizations

Database workloads tend to modify a lot of memory in each epoch (buffer pool, working memory for queries, etc.)

Reduce checkpointing overhead Asynchronous checkpoint compression Disk read tracking

Network optimization Some database workloads are sensitive to the network latency

added by buffering network packets Exploit semantics of database transactions to avoid buffering

Commit protection

19

Send less dataProtect less memory

Page 20: High Availability for Database Systems in Cloud Computing Environments

Async Checkpoint Compression

Database workloads typically involve a large set of frequently changing pages of memory (e.g., buffer pool pages)

Results in a large amount of replication traffic

The DBMS often changes only a small part of the pages Data that is replicated contains redundancy

Reduce replication traffic by only sending the changes to the memory pages (and send them compressed)

20

Page 21: High Availability for Database Systems in Cloud Computing Environments

Async Checkpoint Compression

Protected VM

Xen VMM

Dirty Pages

(epoch i)

LRU Cache

Dirty pages fromepochs [1 … i-1]

to backupCompute deltaand compress

Domain 0

21

Page 22: High Availability for Database Systems in Cloud Computing Environments

Disk Read Tracking

DB BP

Active VM Standby VM

DBMS

P Changes to VM StatePDBP

BP DBMS

DBMS loads pages from disk into its buffer pool (BP) Clean to DBMS, dirty to Remus

Remus synchronizes dirty BP pages in every checkpoint Synchronization of clean BP pages is unnecessary

Can be read from disk at the backup

P

22

Page 23: High Availability for Database Systems in Cloud Computing Environments

Disk Read Tracking Track the memory pages into which disk reads are placed

Do not mark these pages as dirty until they are actually modified

Add an annotation to the replication stream indicating the disk sectors to read to reconstruct these pages

23

Page 24: High Availability for Database Systems in Cloud Computing Environments

Network Optimization Remus buffers every outgoing network packet

Ensures clients never see results of unsafe execution But increases round trip latency by 2-3 orders of magnitude Largest source of overhead for many database workloads Unnecessarily conservative for database systems

Database systems provide transactions with clear consistency and durability semantics

Remus’s TCP-level per-checkpoint transactions are redundant Provide an interface to allow a DBMS to decide which

packets are protected (i.e., buffered until the next checkpoint) and which are unprotected Implemented as a new setsockopt() option in Linux

24

Page 25: High Availability for Database Systems in Cloud Computing Environments

Commit Protection Commit Protection

DBMS only protects transaction control packets (BEGIN TRANSACTION, COMMIT, ABORT)

Other packets are unprotected After failover, a recovery handler runs in the DBMS

at the backup Aborts all in-flight transaction where the client connection

was in unprotected mode Not transparent to the DBMS

Requires minor modifications to the client connection layer 103 LoC for PostgreSQL, 85 LoC for MySQL

Transaction safety is guaranteed

25

Page 26: High Availability for Database Systems in Cloud Computing Environments

Experimental Setup

Backup Server

DBMySQL /

PostgreSQL(Active VM)

Primary Server

Xen 4.0

Gigabit Ethernet

DBMySQL /

PostgreSQL(Standby VM)

Xen 4.0

TPC-C / TPC-H

26

Page 27: High Availability for Database Systems in Cloud Computing Environments

Primary server fails

Failover

27TPC-C on MySQL

Page 28: High Availability for Database Systems in Cloud Computing Environments

Benefits of RemusDB

28

High availability for any DBMS with no code changes Or with very little code changes if we use commit protection “High availability as a service”

Automatic and fully transparent failover to a warmed up system

Next steps Reprotection after a failure One server as the backup for multiple primary servers Administration of RemusDB failover

Page 29: High Availability for Database Systems in Cloud Computing Environments

Outline Introduction RemusDB: Database high availability using

virtualization DBECS: Database high availability (and scalability)

using eventually consistent cloud storage(Under submission)

Conclusion

29

Page 30: High Availability for Database Systems in Cloud Computing Environments

Many cloud storage systems Amazon S3 HBase Cassandra …and more

Scalable, distributed, fault tolerant Support simple read and write operations

write(key, value) value = read(key)

Atomicity only for single-row operations No atomic multi-row reads or writes Interface much simpler than SQL (“NoSQL”)

Cloud Storage

30

Page 31: High Availability for Database Systems in Cloud Computing Environments

Databases Over Cloud Storage

31

Goal: A scalable, elastic, highly available, multi-tenant database service that supports SQL and ACID transactions

Cloud storage system provides scalability, elasticity, and availability. DBMS provides SQL and ACID transactions.

Cloud Storage System

Data Center

DBMS

App App

DBMS

App App

DBMS

App App

DBMS

App App

Cloud Storage System

Data Center

Page 32: High Availability for Database Systems in Cloud Computing Environments

DBECS

32

DBECS: Databases on Eventually Consistent Stores Can replace MySQL with another DBMS Need Cassandra since we want eventual consistency

InnoDB

Cassandra

MySQL

Cassandra I/O

Page 33: High Availability for Database Systems in Cloud Computing Environments

Why Cassandra? Relaxing consistency reduces the write latency of

Cassandra and makes it partition tolerant

Cassandra stores semi-structured rows that belong to column families

Rows are accessed by a key Rows are replicated and distributed by hashing keys

Multi-master replication for each row Enables Cassandra to run in multiple data centers Also gives us partition tolerance DBECS leverages this for disaster tolerance

33

Page 34: High Availability for Database Systems in Cloud Computing Environments

Why Cassandra? Client controls the consistency vs. latency trade-off

for each read and write operation write(1)/read(1) – fast but not necessarily consistent write(ALL)/read(ALL) – consistent but may be slow We posit that database systems can control this trade-

off quite well

Client decides the serialization order of updates Important for consistency in DBECS

Scalable, elastic, highly available Like many other cloud storage systems!

34

Page 35: High Availability for Database Systems in Cloud Computing Environments

Consistency vs. Latency value = read(1, key, column)

Send read request to all replicas of the row (based on key) Return first response received to client Returns quickly but may return stale data

value = read(ALL, key, column) Send read request to all replicas of the row (based on key) Wait until all replicas respond and return latest version to

client Consistent but as slow as the slowest replica

write(1) vs. write(ALL) Send write request to all replicas Client provides a timestamp for each write

Other consistency levels are supported35

Page 36: High Availability for Database Systems in Cloud Computing Environments

Consistency vs. Latency

Which v is returned to the read()? write(1)/read(1): possibly v1, and eventually v2 write(ALL)/read(1): guaranteed to return v2 if successful write(1)/read(ALL): guaranteed to return v2 if successful

36

Data Center 1 Data Center 2

Data Center 3

1- write(k, v1) 2- write(k, v2)

3- v = read(k)

Page 37: High Availability for Database Systems in Cloud Computing Environments

Consistency vs. Latency

37

Experiment on Amazon EC2 – Yahoo! Cloud Serving Benchmark (YCSB) – 4 Cassandra Nodes

Same EC2 Availability Zone

Page 38: High Availability for Database Systems in Cloud Computing Environments

Consistency vs. Latency

38

Two EC2 Availability ZonesSame EC2 Geographic Region

Page 39: High Availability for Database Systems in Cloud Computing Environments

Consistency vs. Latency

39

Two EC2 Regions(US East and US West)

Page 40: High Availability for Database Systems in Cloud Computing Environments

Databases Over Cassandra Make Cassandra look like a disk to the DBMS

tenants Databases stored in one column (in one column family) key = DBMS id + disk block id value = contents of disk block

Cassandra I/O layer maps DBMS reads and writes to Cassandra reads and writes

Which consistency level to use? write(1)/read(1): Fast but may return stale data and provides

no durability guarantees. Not good for a DBMS. write(ALL)/read(1): Returns no stale data and guarantees

durability but writes are slow.

40

Page 41: High Availability for Database Systems in Cloud Computing Environments

Goal of DBECS Achieve the performance of write(1)/read(1) while

maintaining consistency, durability, and availability

Optimistic I/O Use write(1)/read(1) and detect stale data

Client-controlled synchronization Make database updates safe in the face of failures

41

Page 42: High Availability for Database Systems in Cloud Computing Environments

Optimistic I/O Key observation: with write(1)/read(1), most reads

will not return stale data Single writer for each database block Reads unlikely to come soon after writes because of DBMS

buffer pool Cassandra sends writes to all replicas Network topology means that first replica to acknowledge a

write will likely be the first to acknowledge a read

So use write(1)/read(1), detect stale data, and recover from it

42

Page 43: High Availability for Database Systems in Cloud Computing Environments

Optimistic I/O Detecting stale data

Cassandra I/O stores a version number with each database block and remembers the current version of each block

Checks the version number returned by read(1) against the current version number

Recovering from stale data Use read(ALL) Retry the read(1)

When read(1) detects stale data, Cassandra brings the stale replicas up to date (read repair)

43

Page 44: High Availability for Database Systems in Cloud Computing Environments

Implementation Cassandra I/O maintains a version list containing

the version number of the latest write for each accessed block

Initially, this list is empty, so use read(ALL) for all blocks As blocks get used, their latest version numbers get added

to the version list. Use read(1) and check returned version number to detect stale reads.

If version list fills up, evict old blocks Use read(ALL) for any block not on the version list

Optimization: modified Cassandra so that read requests notify Cassandra I/O of oldest and newest version numbers of retrieved blocks

If oldest == newest, all replicas of the block are consistent Can use read(1) without checking returned version numbers

44

Page 45: High Availability for Database Systems in Cloud Computing Environments

Dealing with Failures With write(1), data is not safe With read(ALL), will block if one replica is down Naive solution: use write(ALL)/read(QUORUM) Key observation: Transaction semantics tell us

when writes must be safe and when the DBMS can tolerate unsafe writes

Write Ahead Logging tells us when data needs to be safe (write log before data and flush log on commit)

Database systems explicitly synchronize data at the necessary points, for example, by using fsync()

Need an fsync() for Cassandra Can abort transactions if unsafe writes are lost

45

Page 46: High Availability for Database Systems in Cloud Computing Environments

Client-Controlled Sync Added new type of write in Cassandra: write(CSYNC)

Like write(1), but stores the key of the written row in a sync_pending list

Cassandra client can issue a CSync() call to synchronize all rows in the sync_pending list

To protect against failure, Cassandra I/O Uses write(CSYNC) instead of write(1) Calls CSync() whenever the DBMS calls fsync()

Data or log pages are made safe only when needed Time between write() and CSync() enables latency hiding

Uses read(QUORUM)

46

Page 47: High Availability for Database Systems in Cloud Computing Environments

Examples of Failures Loss of a Cassandra node

Handled by Cassandra Completely transparent to DBMS

Loss of the primary data center (Disaster Recovery) Cassandra needs to be running in multiple data centers Restart the DBMS in a backup data center Log-based recovery brings the database up to date in a

transactionally consistent way

47

Page 48: High Availability for Database Systems in Cloud Computing Environments

Throughput

48

MySQL and Cassandra in Amazon EC2TPC-C Workload – 6 Cassandra Nodes

Page 49: High Availability for Database Systems in Cloud Computing Environments

Scalability

49

Adding DBMS Tenants and Proportionally Increasing the Number of Cassandra Nodes

Page 50: High Availability for Database Systems in Cloud Computing Environments

High Availability

50Failure of Cassandra Node in Primary Data Center

Page 51: High Availability for Database Systems in Cloud Computing Environments

High Availability

51Failure of Cassandra Node in Secondary DC

Page 52: High Availability for Database Systems in Cloud Computing Environments

Disaster Recovery

52Loss of Primary Data Center

Page 53: High Availability for Database Systems in Cloud Computing Environments

Benefits of DBECS Scalable and elastic storage capacity and bandwidth Scalable in the number of database tenants Highly available and disaster tolerant storage tier SQL and ACID transactions for the tenants An interesting point in the spectrum of answers

to the question: “Can consistency scale?”

Missing from DBECS (next steps) Always-up hosted DBMS tenants

DBECS enables DBMS tenant to use standard log-based recovery, but tenant incurs significant down time

Scaling of individual hosted DBMS tenants

53

Page 54: High Availability for Database Systems in Cloud Computing Environments

Conclusion High availability (and scalability) for database

systems can be provided by the cloud infrastructure

Taking advantage of the well-known characteristics of database systems can greatly enhance the solutions

RemusDB: Efficient and transparent database high availability in the virtualization layer

DBECS: Scalability and high availability for database clients built on the Cassandra cloud storage system

54