• No results found

MySQL High-Availability and Scale-Out architectures

N/A
N/A
Protected

Academic year: 2021

Share "MySQL High-Availability and Scale-Out architectures"

Copied!
33
0
0

Loading.... (view fulltext now)

Full text

(1)

MySQL High-Availability and

Scale-Out architectures

Oli Sennhauser

Senior Consultant

[email protected]

(2)

Introduction

• Who we are?

• What we want?

(3)

Table of Contents

• Scale-Up vs. Scale-Out

• MySQL Replication

• MySQL HA solution

• MySQL Cluster

• Application architectural solutions

• Other architectural stuff

• It's your turn...

• Let us build a replication

(4)

When do we think about architecture?

• Performance problems

• HA requirements

(5)

Scale-up vs. Scale-Out

• Scale-up

• Scale-out

t

Relaxation of constraints

(6)

MySQL Replication

• The MySQL answer: Master-Slave-Replication:

Even Oracle uses the expression “scale-out” now!

Master

Slave1 Slave2 Slave3 Application

LB

...

ro rtw

2 types of sessions!!!

(7)

MySQL Replication in detail

M S

Appl

bin-log bin-log

... relay-log

IO thread SQL thread

asynchronous!

relay-log

rtw

ro

• wide distance possible!

• thin line possible!

(8)

MySQL Replication varieties

M

SI SI SI

• Cascaded replication:

for example Yahoo!

S1 S2 S3 S4 S5 S6 S7 S8 ...

...

black hole SE!

(9)

MySQL Replication varieties

M

S2 S3

• HA with “hot standby” Slave:

• active – active fail over!

S1

Sbackup Sstandby

Appl

VIP HA solution

(10)

MySQL HA solution

M

S2 S3

• HA with MySQL:

• 99.99% HA (four nine)

• active – passive fail over!

S1

M' Appl

VIP

DRBD

heartbeat

(11)

MySQL HA solution

M

S2 S3

• HA with MySQL and SAN:

S1

M' Appl

VIP

SAN

heartbeat

(12)

Multi-Master Replication

M1 S12 S13

• actually Master-Master Replication

• This architecture does NOT solve your write problems!!!

S11

Appl

M2 Appl

VIP/LB

S22 S23 S21

(13)

Multi-Master Replication

M1

S12 S13

• HA Multi-Master Replication

S11

M2

S22 S23 S21

M2' Appl

VIP

DRBD

M1'

Appl

VIP

DRBD

VIP/LB

(14)

Shared disk cluster

DB1

• This is in 99.9% of the cases NOT your solution!!!

• It looks like Oracle RAC but MySQL does NOT (yet) have the instruments needed!

• Can be useful in some special kinds of reporting.

DB2

shared disk

DB2 ro!

(15)

Where are we now?

• The architectures above solved:

– your read problems.

– some HA requirements.

• But they did not solve:

– your write problems!

• And what when we need:

– higher HA?

– synchronous replication?

– more write speed?

(16)

MySQL Cluster

• Shared-nothing architecture

• Synchronous replication (2-Phase commit)

• Fast automatic fail over

• High performance (also writing)

• High transactional throughput

• No special components required

• In-Memory database (in 5.1 also disk support)

• Scalable, 1000's of transactions per second

• 99.999% HA (five nine)

• On-line upgrade path (at least on GA within same version)

(17)

MySQL Cluster architecture

Application Application Application

MySQL Server

NDB Cluster

(Data nodes)

MySQL Server MySQL

Server

DB DB

DB DB

MGM Server

MGM client Application

Application Application

config.ini my.cnf

SQL­Nodes

Data­Nodes

Mgmt­Nodes

(18)

MySQL Cluster HA features

MySQL Server MySQL Server

Data Node

Data Node Data

Node Data Node

NDB

Storage Engine

Management Server Management

Server NDB API

NDB API

MySQL Cluster

Data NodeData

Node Data

Node Data Node MySQL Server MySQL Server MySQL

Server MySQL Server

Management Server Management

Server MySQL

Server MySQL

Server MySQL

Server MySQL Server

X X X X

X X X

(19)

Cluster with Replication

S2 S3

• for read scale-out (Reporting):

S1 Appl

ndbd ndbd ndbd ndbd

mysqld mysqld mysqld

Reporting rw

(20)

Cluster with Replication

• Cluster-Cluster replication for disaster fail over (MySQL 5.0):

Appl

ndbd ndbd ndbd ndbd

mysqld mysqld mysqld

rw

ndbd ndbd ndbd ndbd

mysqld mysqld mysqld

fail over

(21)

Cluster with Replication

• Cluster-Cluster replication for disaster fail over (MySQL 5.1):

Appl

ndbd ndbd ndbd ndbd

mysqld mysqld mysqld

rw

ndbd ndbd ndbd ndbd

mysqld mysqld mysqld

fail over

(22)

Cluster with Replication

• circular Cluster-Cluster replication (>= MySQL 5.1.18?):

(23)

Cluster examples

• Session handling

• Telecom (Mobile)

• VoIP

• RSS-Feed aggregation

• Mail

• On-line Games

• Use cluster where

– you need HA

– you have high write load

– you do little Joins and Grouping

(24)

How to go on?

• Read is a caching problem!

More RAM or scale-out.

Write is a batching problem!

Batch your load,

Buy stronger I/O system.

Use MySQL Cluster.

SSD!

What then?

(25)

SSD disruption

• I/O system without any movable parts!

• SSD = Solid State disk (Flash memory, NAND, NOR chips, RAM-SAN).

• During the last year(s)

• Price from 15'000 USD / 160 Gbyte -> 100 USD / 32 Gbyte

• 10-50 times faster than mechanical I/O systems

• 1 Mio write cycles dead :-( (special FS!)

• RAM: Huge amount of memory is cheap!

This will disrupt the database world!

(26)

What then?

• With or without SSD we will reach a physical limit. What then?

• Application partitioning:

– Split applications

• OLTP vs. OLAP

• all in one

– Segment your application

(27)

Application partitioning

• OLTP vs. OLAP

– hot business data (trx) vs. “old” reporting data

• “All in one”

– Sessions, user tracking, ads, chat, booking

• Segment

– split by for example 1 Mio users (split by user_id).

(28)

Architecture examples

(29)

Architecture examples

(30)

Architecture examples

(31)

Architecture examples

(32)

Some more architecture stuff?

• Databases are slow!!!

Whenever possible try to avoid databases! Use memcached for example.

• The SP trap.

Stored Procedures are a lock in! Try to avoid SP!

• Use Materialized Views (MV) and/or shadow tables.

• VM/SAN is nice for consolidation but not for performance/scale-out!

• Backup and Staging

• MySQL – Proxy

(33)

Now it's your turn...

• Your problems?

• Let us build a replication...

References

Related documents