79
Building Highly Available Web Applications Emmanuel Cecchet Chief architect - Continuent http://www.continuent.org

Building Highly Available Web Applications

  • Upload
    ermin

  • View
    26

  • Download
    0

Embed Size (px)

DESCRIPTION

Building Highly Available Web Applications. Emmanuel Cecchet Chief architect - Continuent. http://www.continuent.org. High availability. The magic nines. Few definitions. MTBF Mean Time Between Failure Total MTBF of a cluster must combine MTBF of its individual components - PowerPoint PPT Presentation

Citation preview

Page 1: Building Highly Available Web Applications

Building Highly Available Web Applications

Emmanuel CecchetChief architect - Continuent

http://www.continuent.org

Page 2: Building Highly Available Web Applications

2

High availability

• The magic nines

Percent uptime

Downtime/month

Downtime/year

99.0% 7.2 hours 3.65 days

99.9% 43.2 minutes 8.76 hours

99.99% 4.32 minutes 52.56 minutes

99.999% 0.43 minutes 5.26 minutes

99.9999% 2.6 seconds 31 seconds

Page 3: Building Highly Available Web Applications

3

Few definitions• MTBF

• Mean Time Between Failure• Total MTBF of a cluster must combine MTBF of its

individual components• Consider mean-time-between-system-abort

(MTBSA) or mean-time-between-critical-failure (MTBCF)

• MTTR• Mean Time To Repair• How is the failure detected?• How is it notified?• Where are the spare parts for hardware?• What does your support contract say?

Page 4: Building Highly Available Web Applications

4

Problem: Database is the weakest link

• Clients connect to the application server• Application server builds web pages with data

coming from the database• Application server clustering solves application

server failure• Database outage causes overall system outage

Internet

Database

DatabaseDisk

Applicationservers

Page 5: Building Highly Available Web Applications

5

Disk replication/clustering

• Eliminates the single point of failure (SPOF) on the disk

• Disk failure does not cause database outage

• Database outage problem still not solved

Internet

Database

Database disks

Applicationservers

Page 6: Building Highly Available Web Applications

6

Database clustering with shared disk

• Multiple database instances share the same disk• Disk can be replicated to prevent SPOF on disk• No dynamic load balancing• Database failure not transparent to users (partial

outage)• Manual failover + manual cleanup needed

Internet

Databases DatabaseDisks

Applicationservers

Page 7: Building Highly Available Web Applications

7

Master/slave replication• Lazy replication at the disk or database level• No scalability• Data lost at failure time• System outage during failover to slave• Failover can take several hours

Internet

MasterDatabase

DatabaseDisks

Applicationservers

Slave Database

log shippinghot standby

Page 8: Building Highly Available Web Applications

8

Internet

Web frontend

App. server Master

Scaling the database tierMaster-slave replication

• Cons• failover time/data loss on master failure• read inconsistencies• scalability

Page 9: Building Highly Available Web Applications

9

Internet

• Cons• atomic broadcast scalability• no client side load balancing• heavy modifications of the database engine

Atomicbroadcast

Scaling the database tierAtomic broadcast

Page 10: Building Highly Available Web Applications

10

Scaling the database tier – SMP

Internet

Web frontend

App. server

Well-known database

vendor here

Database

Well-known hardware +database vendors here

• Cons• Scalability limit• Cost

Page 11: Building Highly Available Web Applications

11

Internet

• Database tier should be• scalable• highly available• without modifying the client application• database vendor independent• on commodity hardware

Sequoia motivations

Page 12: Building Highly Available Web Applications

12

Transparent failover• Failures can happen

• in any component• at any time of a request execution• in any context (transactional, autocommit)

• Transparent failover • masks all failures at any time to the client • perform automatic retry and preserves

consistency

Internet

Sequoia

Page 13: Building Highly Available Web Applications

13

Sequoia competitive advantages

• High availability with fully transparent failover• Online upgrade and maintenance operations• Scalability with dynamic load balancing• Commodity hardware• No modification to existing client applications• Database vendor independent• Heterogeneity support• Platform independent

Page 14: Building Highly Available Web Applications

14

Open source database clustering requirements

Feature MySQL replicati

on

MySQL cluster

Slony-I Sequoia

Commodity hardware

Yes Yes Yes Yes

Application modifications

Yes if reading from slaves

Yes (NDB) Yes if reading from slaves

No but driver update needed

Database modifications

No (built-in) No (built-in)

Recompile No

DB support MySQL 3.23, 4.x or 5.x

MySQL 5.x PostgreSQL 7.x, 8.x

Derby, MySQL, PostgreSQL any version

License GPL/Comm. GPL/Comm.

BSD APL

Page 15: Building Highly Available Web Applications

15

Open source database clustering features

Feature MySQL replicati

on

MySQL cluster

Slony-I Sequoia

Data loss on failure

Yes No Yes No

Transparent failover

No No No Yes

Disaster recovery

Yes Yes Yes Yes

Queries load balancing

No Yes, static

No Yes, dynamic

Add node on the fly

Yes (slave) No Yes (slave) Yes

Online upgrades

No No No Yes

Page 16: Building Highly Available Web Applications

16

Outline

•RAIDb•Sequoia•Building an HA solution•Scalability•High availability

Page 17: Building Highly Available Web Applications

17

RAIDb concept• Redundant Array of Inexpensive

Databases• RAIDb controller

• gives the view of a single database to the client

• balance the load on the database backends

• RAIDb levels offers various tradeoff of performance and fault tolerance

Page 18: Building Highly Available Web Applications

18

RAIDb levels• RAIDb-0

• partitioning• no duplication and no fault tolerance• at least 2 nodes

table 2 & 3 table ...

RAIDb controller

table n-1table 1 table n

SQL requests

Page 19: Building Highly Available Web Applications

19

RAIDb levels• RAIDb-1

• mirroring• performance bounded by write

broadcast• at least 2 nodes

Full DB Full DB

RAIDb controller

Full DBFull DB Full DB

SQL requests

Page 20: Building Highly Available Web Applications

20

RAIDb levels• RAIDb-2

• partial replication• at least 2 copies of each table for fault tolerance• at least 3 nodes

table x table y

RAIDb controller

table x & yFull DB table z

SQL requests

Page 21: Building Highly Available Web Applications

22

Outline

•RAIDb•Sequoia•Building an HA solution•Scalability•High availability

Page 22: Building Highly Available Web Applications

23

Sequoia overview• Middleware implementing RAIDb

• 100% Java implementation• open source (Apache v2 License)

• Two components• Sequoia driver (JDBC, ODBC, native lib)• Sequoia Controller

• HA and load balancing features• Database neutral (generic ANSI SQL)

Page 23: Building Highly Available Web Applications

24

JVM

Sequoia JDBC driver

Sequoiacontroller

JVM

DerbyJDBC Driver Derby

Sequoia architectural overview

Page 24: Building Highly Available Web Applications

25

Sequoia drivers (1/2)• Visit http://carob.continuent.org

Sequoia controller

MySQL JDBC driver

Java client

Sequoia JDBC driver

Sequoia protocol

Carob C++ API

ODBSequoia

PHP client

.Net client

ODBC client

libmysql

MySQL protocol

CustomC/C++clientlibmy

sequoia

MySQL JDBC driver

Sequoia controller

Derby JDBC driver

Derby protocol

Derby JDBC driver

Page 25: Building Highly Available Web Applications

26

Sequoia drivers (2/2)• Provide load balancing between

controllers for connection establishment• Controller failure detection• Transparent failover for any request in

any context (including metadata) on controller failure

• Transparent SQL proxying• Optional SSL if needed

Page 26: Building Highly Available Web Applications

27

Inside the Sequoia Controller

Sequoia Controller

DB2

Sequoia driver

DB2

Virtual database 1

Database Backend

Connection Manager

Database Backend

Connection Manager

Request Manager

Query result cache

Scheduler

Load balancer

DB2 JDBC driver

DB2 JDBC driver

Recovery Log

Authentication Manager

DB2

Database Backend

Connection Manager

DB2 JDBC driver

Virtual database 2

Database Backend

Connection Manager

Database Backend

Connection Manager

Request Manager

Query result cache

Scheduler

Load balancer

Recovery Log

Authentication Manager

Oracle JDBC driver

Oracle

JMX Server

Monitoring

JMX administration console

MS SQL

MS SQL JDBC driver

Sequoia driver

Client application (Servlet, EJB, ...)

Sequoia driver

HTTP RMI ...

Client application (Servlet, EJB, ...)

Client application (Servlet, EJB, ...)

Checkpointing service

Database dumps management

Configuration

Page 27: Building Highly Available Web Applications

28

DB2

Sequoia driver

Java client program

(Servlet, EJB, ...)

DB2

Virtual database

Database Backend

Connection Manager

Database Backend

Connection Manager

Request Manager

Request Cache

Scheduler

Load balancer

DB2 JDBC driver

DB2 JDBC driver

Recovery Log

Authentication Manager

DB2

Database Backend

Connection Manager

DB2 JDBC driver

Virtual Database• Gives the view of a single

database• Establishes the mapping

between the database name used by the application and the backend specific settings

• Backends can be added and removed dynamically

• Backends can be transferred between controllers

• configured using an XML configuration file

Page 28: Building Highly Available Web Applications

29

DB2

Sequoia driver

Java client program

(Servlet, EJB, ...)

DB2

Virtual database

Database Backend

Connection Manager

Database Backend

Connection Manager

Request Manager

Request Cache

Scheduler

Load balancer

DB2 JDBC driver

DB2 JDBC driver

Recovery Log

Authentication Manager

DB2

Database Backend

Connection Manager

DB2 JDBC driver

Authentication Manager

• Matches real login/password used by the application with backend specific login/ password

• Administrator login to manage the virtual database

• Transparent login proxying available

Page 29: Building Highly Available Web Applications

30

DB2

Sequoia driver

Java client program

(Servlet, EJB, ...)

DB2

Virtual database

Database Backend

Connection Manager

Database Backend

Connection Manager

Request Manager

Request Cache

Scheduler

Load balancer

DB2 JDBC driver

DB2 JDBC driver

Recovery Log

Authentication Manager

DB2

Database Backend

Connection Manager

DB2 JDBC driver

Scheduler• Manages concurrency control• Provides support for cluster-

wide checkpoints• Assigns unique ids to

requests and transactions• Ensure serializable

transactional order• Relies on database (row-

level) locking

Page 30: Building Highly Available Web Applications

31

DB2

Sequoia driver

Java client program

(Servlet, EJB, ...)

DB2

Virtual database

Database Backend

Connection Manager

Database Backend

Connection Manager

Request Manager

Request Cache

Scheduler

Load balancer

DB2 JDBC driver

DB2 JDBC driver

Recovery Log

Authentication Manager

DB2

Database Backend

Connection Manager

DB2 JDBC driver

Request cache• 3 optional caches

• tunable sizes

• parsing cache• parse request skeleton only once• INSERT INTO t VALUES (?,?,?)

• metadata cache• column metadata• fields of a request

• result cache• caches results from SQL requests• tunable consistency• optimizations for findByPk requests

Page 31: Building Highly Available Web Applications

33

DB2

Sequoia driver

Java client program

(Servlet, EJB, ...)

DB2

Virtual database

Database Backend

Connection Manager

Database Backend

Connection Manager

Request Manager

Request Cache

Scheduler

Load balancer

DB2 JDBC driver

DB2 JDBC driver

Recovery Log

Authentication Manager

DB2

Database Backend

Connection Manager

DB2 JDBC driver

Load balancer 1/2• RAIDb-0

• query directed to the backend having the needed tables

• RAIDb-1• read executed by current thread• write multicast through group

communication and executed in parallel• asynchronous execution possible• if one node fails but others succeed,

failing node is disabled

• RAIDb-2• same as RAIDb-1 except that writes are

sent only to nodes owning the updated table

Page 32: Building Highly Available Web Applications

34

DB2

Sequoia driver

Java client program

(Servlet, EJB, ...)

DB2

Virtual database

Database Backend

Connection Manager

Database Backend

Connection Manager

Request Manager

Request Cache

Scheduler

Load balancer

DB2 JDBC driver

DB2 JDBC driver

Recovery Log

Authentication Manager

DB2

Database Backend

Connection Manager

DB2 JDBC driver

Load balancer 2/2• Static load balancing policies

• Round-Robin (RR)• Weighted Round-Robin (WRR)

• Least Pending Requests First (LPRF)• request sent to the node that

has the shortest pending request queue

• efficient even if backends do not have homogeneous performance

Page 33: Building Highly Available Web Applications

35

DB2

Sequoia driver

Java client program

(Servlet, EJB, ...)

DB2

Virtual database

Database Backend

Connection Manager

Database Backend

Connection Manager

Request Manager

Request Cache

Scheduler

Load balancer

DB2 JDBC driver

DB2 JDBC driver

Recovery Log

Authentication Manager

DB2

Database Backend

Connection Manager

DB2 JDBC driver

Connection Manager• Sequoia JDBC driver provides

transparent connection pooling• Connection pooling for a

backend• no pooling• blocking pool• non-blocking pool• dynamic pool

• Connection pools defined on a per login basis• resource management per login• dedicated connections for admin

Page 34: Building Highly Available Web Applications

36

DB2

Sequoia driver

Java client program

(Servlet, EJB, ...)

DB2

Virtual database

Database Backend

Connection Manager

Database Backend

Connection Manager

Request Manager

Request Cache

Scheduler

Load balancer

DB2 JDBC driver

DB2 JDBC driver

Recovery Log

Authentication Manager

DB2

Database Backend

Connection Manager

DB2 JDBC driver

Recovery Log• Transactional log for

recovery/resync• Checkpoints are

associated with database dumps

• Record all updates and transaction markers since a checkpoint

• Store log information in a database

Page 35: Building Highly Available Web Applications

37

Functional overview

• Connection establishment• Read request• Write request• Failure handling• Recovery• Summary

Page 36: Building Highly Available Web Applications

38

Connection establishment• Sequoia JDBC URL

• jdbc:sequoia://controller1[:port1],controller2[:port2]/vdbname

• Driver connection to a controller according to a policy defined in the URL (random, round-robin, ordered, …)

• Controller connections to a physical database use a connection pool defined per backend

• All queries on a driver connection go to the same controller but controller load balance queries on the underlying backends

Page 37: Building Highly Available Web Applications

39

Sequoia Controller

Derby

Sequoia driver

Derby

Virtual database 1

Database Backend

Connection Manager

Database Backend

Connection Manager

Request Manager

Query result cache

Scheduler

Load balancer

Derby JDBC driver

Derby JDBC driver

Recovery Log

Authentication Manager

Derby

Database Backend

Connection Manager

Derby JDBC driver

Sequoia driver

Client application (Servlet, EJB, ...)

Client application (Servlet, EJB, ...)

connect myDBconnect login, passwordexecute SELECT * FROM t

ordering

exec

RR, WRR, LPRF, … get connection from poolupdate cache

(if available)

Sequoia read request

Page 38: Building Highly Available Web Applications

40

Write request• Query broadcast using total order between

controllers• Backends execute query in parallel (possibly

asynchronously)• Automatically disable backends that fail if others

succeed• Update recovery log (transactional log)

asynchronously• Non-conflicting transactions execute in parallel

• table-based locking used as a hint for detecting conflicts• conflicting queries execute in a single-threaded queue• stored procedures execute one at a time

Page 39: Building Highly Available Web Applications

41

Sequoia Controller

Distributed Request Manager

Sequoia Controller

Distributed Request Manager

Sequoia driver

Virtual database 1

Database Backend

Connection Manager

Database Backend

Connection Manager

Derby JDBC driver

Derby JDBC driver

Virtual database 2

Database Backend

Connection Manager

Database Backend

Connection Manager

Request Manager

Query result cache

Scheduler

Load balancer

Authentication Manager

Derby JDBC driver

Sequoia driver

Client application (Servlet, EJB, ...)

Sequoia driver

Client application (Servlet, EJB, ...)

Client application (Servlet, EJB, ...)

Request Manager

Query result cache

Scheduler

Load balancer

Authentication Manager

Recovery Log

Recovery Log

Derby Derby Derby

Recovery Database

Embedded Derby

Derby JDBC driver

Derby

Recovery Database

Embedded Derby

Database Backend

Connection Manager

Database Backend

Connection Manager

Derby JDBC driver

Derby

Derby JDBC driver

Derby

Database Backend

Connection Manager

Database Backend

Connection Manager

Derby JDBC driver

Derby JDBC driver

Derby Derby

jdbc:sequoia://node1,node2/myDB

Total order reliable multicast

Controller replication

Page 40: Building Highly Available Web Applications

42

Sequoia failure handling (1/2)

• Failure of a connection to a controller• transparently reconnected to another controller

(according to user defined policy)• failure inside a transaction restores the

transactional context upon reconnection

• backend failure• backend removed from load balancer (no

noticeable failover time)• failure during read: retry on another backend• failure during write: ignored if successful on

other backends

Page 41: Building Highly Available Web Applications

43

Sequoia failure handling (2/2)

• controller failure• database backends attached to dead

controller are lost• clients are transparently reconnected to

another controller (according to user defined policy)

• failure during read: transparently retried (even within a transaction)

• failure during write: retrieve from remaining controller(s) failover cache

Page 42: Building Highly Available Web Applications

44

Sequoia Controller

Derby

Sequoia driver

Derby

Virtual database 1

Database Backend

Connection Manager

Database Backend

Connection Manager

Request Manager

Query result cache

Scheduler

Load balancer

Derby JDBC driver

Derby JDBC driver

Recovery Log

Authentication Manager

Derby

Database Backend

Connection Manager

Derby JDBC driver

Sequoia driver

Client application (Servlet, EJB, ...)

Client application (Servlet, EJB, ...)

• No 2 phase-commit• parallel

transactions• failed nodes are

automatically disabled

execute INSERT INTO t …

Node failure with Sequoia

Page 43: Building Highly Available Web Applications

45

Outline

•RAIDb•Sequoia•Building an HA solution•Scalability•High availability

Page 44: Building Highly Available Web Applications

46

Internet

• Apache clustering• L4 switch, RR-DNS, One-IP techniques, LVS, Linux-HA, …

• Web tier clustering• mod_jk (T4), mod_proxy/mod_rewrite (T5), session

replication

• Database clustering• Sequoia + any database

Highly available web site

mod-jkRR-DNS

Parsing cacheResult cache

Metadata cache

embedded

Page 45: Building Highly Available Web Applications

47

Internet

• Consider MTBF (Mean time between failure) of every hardware and software component

• Take MTTR (Mean Time To Repair) into account to prevent long outages

• Tune accordingly to prevent trashing

Highly available web applications

Sequoia

Page 46: Building Highly Available Web Applications

48

Group communication

• Group communication is the base for replication

• Different tiers might have different needs• Ordering (FIFO, Total, causal, …)• Delivery (Best effort, reliable, …)• Group Membership (View synchrony, …)• Network protocols (UDP, TCP, …)• LAN vs WAN

Page 47: Building Highly Available Web Applications

49

Appia• Flexible group communication library

available under APL v2 (http://appia.continuent.org)

• Composed by• A core used to compose protocols• A set of protocols

• group communication, ordering guarantees, atomic broadcast, among other properties

• Created and supported by the Appia team• University of Lisbon, Portugal

• DIALNP research group

Page 48: Building Highly Available Web Applications

50

Appia Protocol Composition (example)

TCP

Total Order

Application

Group Communication

Atomic BroadcastChannel Group Communication

Channel

Page 49: Building Highly Available Web Applications

51

Appia features (1/2)• Possible transport protocols

• UDP / IP Multicast• TCP• TCP+SSL

• Existing protocols• Causal order• Total order

• Sequencer-based; • Token-based; • Total-Causal;• Hybrid (Adaptive Sequencer/Causal);• Optimistic (sequencer-based) Uniform Total Order

Page 50: Building Highly Available Web Applications

52

Appia features (2/2)• Event-based delivery model

• Support for asynchronous events

• Optional view synchrony with failure detector

• Support for QoS constraints

Page 51: Building Highly Available Web Applications

53

Sequoia/Java configuration• Keep all original database specific

settings as is (SQL dialect, connection test statements, …)

• Copy sequoia-driver.jar in classpath• Set driver class name to

org.continuent.sequoia.driver.Driver • Set JDBC URL to

jdbc:sequoia://host1,host2/mydb

Page 52: Building Highly Available Web Applications

54

Sequoia/PHP configuration

• ODBC• Copy libodbsequoia.so in /usr/lib• Configure odbc.ini (look at the examples)

• MySQL native library• Install libMySequoia rpm or dbm package• LD_PRELOAD=/usr/lib/libmysequoia.so

your_program• $link = mysqli_connect("node1 node2",

"user", "password", "db1"); • Perl

• Use DBD:JDBC module

Page 53: Building Highly Available Web Applications

55

Configuring Sequoia with Derby Network server

• Virtual database configuration file

<VirtualDatabase name="myDB"><Distribution>

<MessageTimeouts/></Distribution>…<DatabaseBackend name=“derby1” driver=“org.apache.derby.jdbc.ClientDriver” url= “jdbc:derby:net://localhost:1527/xpetstore;create=true;retrieveMessagesFromServerOnGetMessage=true;”

connectionTestStatement="values 1"> <ConnectionManager …/>

</DatabaseBackend>

Page 54: Building Highly Available Web Applications

56

Configuring Sequoia Clustering with Derby (1/2)

<RequestManager> <RequestScheduler> <RAIDb-1Scheduler level=“passThrough"/> </RequestScheduler>

<RequestCache> <MetadataCache/> <ParsingCache/>

<ResultCache granularity="table" /> </RequestCache>

<LoadBalancer> <RAIDb-1> <RAIDb-1-LeastPendingRequestFirst/> </RAIDb-1> </LoadBalancer>

Page 55: Building Highly Available Web Applications

57

Configuring Sequoia Clustering with Derby (2/2)

<RecoveryLog> <JDBCRecoveryLog

driver="org.apache.derby.jdbc.ClientDriver “url="jdbc:derby:net://localhost:1529/xpetstore;

create=true;retrieveMessagesFromServerOnGetMessage=true;" login="APP" password="APP">

<RecoveryLogTable tableName="RECOVERY" idColumnType="BIGINT NOT NULL"

sqlColumnName="sqlStmt“sqlColumnType="VARCHAR(8192) NOT NULL“extraStatementDefinition=",PRIMARY KEY (id)"/>

<CheckpointTable tableName="CHECKPOINT"/> <BackendTable tableName="BACKENDTABLE"/> <DumpTable tableName=“DUMPTABLE”/>

</JDBCRecoveryLog> </RecoveryLog>

</RequestManager></VirtualDatabase>

Page 56: Building Highly Available Web Applications

58

Sequoia to access Derby embedded

Sequoia controller

Embedded Derby

Java client

Sequoia JDBC driver

Sequoia protocol

Carob C++ API

ODBSequoia

PHP client

.Net client

ODBC client

DB X native client

CustomC/C++client

DB X Native API.

jdbc:derby:path;create=true

JVM

Page 57: Building Highly Available Web Applications

59

Outline

•RAIDb•Sequoia•Building an HA solution•Scalability•High availability

Page 58: Building Highly Available Web Applications

60

Sequoia vertical scalability

• allows nested RAIDb levels• allows tree architecture for scalable

write broadcast• Sequoia driver re-injected in Sequoia

controller

Page 59: Building Highly Available Web Applications

61

Advanced Configurations Vertical Scalability Mixed Horizontal and Vertical Scalability

DB 4DB 3

DB native JDBC driver

DB 5

Sequoia driver

DB 1 DB 2

DB native JDBC driver

DB 6

DB native JDBC driver

DB7

Sequoia controller Partial replication

Sequoia controller Full replication

Sequoia controller Full replication

Sequoia controller Full replication

Sequoia driverJVM

Client program Sequoia

driver

JVM

Client program

Sequoia driver

JVM

Client program

DB 6DB 5

DB native JDBC driver

DB 7

Sequoia driver

DB 1 DB 2

DB native JDBC driver

DB 3

DB native JDBC driver

DB 4

Sequoia controller Full replication

Sequoia controller Full replication

Sequoia controller Full replication

Sequoia controller Full replication

Sequoia driverJVM

Client program

Sequoia driver

JVM

Client program

Sequoia driver

JVM

Client program

Sequoia driver

Sequoia driver

DB 9

DB native JDBC driver

DB 10

Sequoia controller Full replication

DB 8

DB 12

DB native JDBC driver

DB 13

Sequoia controller Full replication

DB 11

Page 60: Building Highly Available Web Applications

62

TPC-W benchmark (Amazon.com)

• Nearly linear speedups with the shopping mix

0

200

400

600

800

1000

1200

1400

1600

0 2 4 6

Number of nodes

Th

rou

gh

pu

t in

req

uests

per

min

ute

Single Database

Full replication

Partial replication

Page 61: Building Highly Available Web Applications

63

Performance vs Scalability• Sequoia is not a parallel database

• No parallelization of query execution plan• Query do not go faster when database is

not loaded

• Sequoia distributes the load evenly• Constant response time when load

increases• Better throughput when load surpasses

capacity of a single database

Page 62: Building Highly Available Web Applications

64

Understanding scalability (1/2)Performance vs. Time

0

50

100

150

200

250

300

350

400

450

500

00:00:00 01:12:00 02:24:00 03:36:00 04:48:00 06:00:00 07:12:00 08:24:00 09:36:00 10:48:00

Time (sec.)

Re

sp

on

se

tim

e

1 Database - Load in users

1 Database - Response time

Sequoia 2 DBs - Load in users

Sequoia 2 DBs - Response time

20 users

Single DB

Sequoia

Page 63: Building Highly Available Web Applications

65

Understanding scalability (2/2)Performance vs. Time

0

500

1000

1500

2000

2500

00:00:00 00:28:48 00:57:36 01:26:24 01:55:12 02:24:00 02:52:48

Time (sec.)

Re

sp

on

se

tim

e

1 DB - Load in users

1 DB - Response time

Sequoia 2DB - Load in users

Sequoia 2 DB - Response time

90 users

Single DB

Sequoia

Page 64: Building Highly Available Web Applications

66

Outline

•RAIDb•Sequoia•Building an HA solution•Scalability•High availability

Page 65: Building Highly Available Web Applications

67

Derby

C-JDBC Controller

Derby JDBC driver

C-JDBC driver

JVM

EJB Container JOnAS, WebLogic,

JBoss, WebSphere, ...

disabled

dump for initial

checkpoint

Recovery Log

disabled

Initializing the cluster

• Dump initial Derby database using backuper

• RecoveryLog tables are initialized

Page 66: Building Highly Available Web Applications

68

Derby

C-JDBC Controller

Derby JDBC driver

C-JDBC driver

JVM

EJB Container JOnAS, WebLogic,

JBoss, WebSphere, ...

enabled

dump for initial

checkpoint

Recovery Log

JDBC Recovery Log

enabled

Logging

• Backend is enabled• All database

updates are logged (SQL statement, user, transaction, …)

Page 67: Building Highly Available Web Applications

69

Derby

C-JDBC Controller

Derby JDBC driver

C-JDBC driver

JVM

EJB Container JOnAS, WebLogic,

JBoss, WebSphere, ...

dump for initial

checkpoint

Recovery Log

Derby Derbydisabled disabledenabled

enabled

JDBC Recovery Log

Adding new backends 1/3

• Add new backends while system online

• Restore dump

Page 68: Building Highly Available Web Applications

70

Derby

C-JDBC Controller

Derby JDBC driver

C-JDBC driver

JVM

EJB Container JOnAS, WebLogic,

JBoss, WebSphere, ...

dump for initial

checkpoint

Recovery Log

Derby Derbyenabled

enabled

JDBC Recovery Log

disableddisabled

Adding new backends 2/3

• Replay updates from the log

Page 69: Building Highly Available Web Applications

71

Derby

C-JDBC Controller

Derby JDBC driver

C-JDBC driver

JVM

EJB Container JOnAS, WebLogic,

JBoss, WebSphere, ...

dump for initial

checkpoint

Recovery Log

Derby Derbyenabled

enabled

JDBC Recovery Log

enabledenabled

Adding new backends 3/3

• Auto-enable backends when done

Page 70: Building Highly Available Web Applications

72

...

dump for last

checkpoint

Derby

C-JDBC Controller

Derby JDBC driver

C-JDBC driver

JVM

EJB Container JOnAS, WebLogic,

JBoss, WebSphere, ...

dump for last

checkpoint

Recovery Log

Derby Derbyenabled

enabled

JDBC Recovery Log

enableddisabled

dump for initial

checkpoint

Taking new dumps (1/3)

• Calling backup command on a backend will automatically disable/backup/re-enable

Page 71: Building Highly Available Web Applications

73

Taking new checkpoints (2/3)

• Replay missing updates from log

dump for

checkpoint

...

dump for last

checkpoint

dump for last

checkpoint

dump for initial

checkpoint

Derby

C-JDBC Controller

Derby JDBC driver

C-JDBC driver

JVM

EJB Container JOnAS, WebLogic,

JBoss, WebSphere, ...

Recovery Log

Derby Derbyenabled

enabled

JDBC Recovery Log

disabled enabled

Page 72: Building Highly Available Web Applications

74

Derby

C-JDBC Controller

Derby JDBC driver

C-JDBC driver

JVM

EJB Container JOnAS, WebLogic,

JBoss, WebSphere, ...

dump for

checkpoint

Recovery Log

Derby Derbyenabled

enabled

JDBC Recovery Log

enabledenabled

...

dump for last

checkpoint

dump for last

checkpoint

dump for initial

checkpoint

Making new checkpoints (3/3)

• Auto-enable backend when done

Page 73: Building Highly Available Web Applications

75

Derby

C-JDBC Controller

Derby JDBC driver

C-JDBC driver

JVM

EJB Container JOnAS, WebLogic,

JBoss, WebSphere, ...

dump for

checkpoint

Recovery Log

Derby Derbyenabled

enabled

JDBC Recovery Log

enableddisabled

...

dump for last

checkpoint

dump for last

checkpoint

dump for initial

checkpoint

Handling failures• A node fails!• Automatically

disabled but administrator fix needed

Page 74: Building Highly Available Web Applications

76

...

dump for last

checkpoint

Derby

C-JDBC Controller

Derby JDBC driver

C-JDBC driver

JVM

EJB Container JOnAS, WebLogic,

JBoss, WebSphere, ...

dump for last

checkpoint

Recovery Log

Derby Derbyenabled

enabled

JDBC Recovery Log

enableddisabled

dump for initial

checkpoint

Recovery 1/3

• Restore latest dump

Page 75: Building Highly Available Web Applications

77

dump for

checkpoint

...

dump for last

checkpoint

dump for last

checkpoint

dump for initial

checkpoint

Derby

C-JDBC Controller

Derby JDBC driver

C-JDBC driver

JVM

EJB Container JOnAS, WebLogic,

JBoss, WebSphere, ...

Recovery Log

Derby Derbyenabled

enabled

JDBC Recovery Log

disabled enabled

Recovery 2/3

• Replay missing updates from log

Page 76: Building Highly Available Web Applications

78

Recovery 3/3

• Re-enable backend when done

Derby

C-JDBC Controller

Derby JDBC driver

C-JDBC driver

JVM

EJB Container JOnAS, WebLogic,

JBoss, WebSphere, ...

dump for

checkpoint

Recovery Log

Derby Derbyenabled

enabled

JDBC Recovery Log

enabledenabled

...

dump for last

checkpoint

dump for last

checkpoint

dump for initial

checkpoint

Page 77: Building Highly Available Web Applications

79

Current limitations• Distributed joins• Some JDBC 3.0 extensions• XA support through XAPool only• Triggers and updateable views

supported with limitations (fully available in Sequoia 3.0)

• WAN network partition and reconciliation not supported

Page 78: Building Highly Available Web Applications

80

Summary• Multi-tier HA

• replication needed at each tier• Appia group communication

• Sequoia• high availability with fully transparent

failover• performance scalability

• Visit http://www.continuent.org

Page 79: Building Highly Available Web Applications

81

Q&A_________

Thanks to all users and contributors ...

http://www.continuent.org