fossasia 2015: mysql group replication

32
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. | 1 MySQL Group Replication Shivji Jha ([email protected]) Software Developer, MySQL Replication Team 2015

Upload: shivji-kumar-jha

Post on 14-Jul-2015

1.691 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: FOSSASIA 2015: MySQL Group Replication

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. | 1

MySQL Group Replication

Shivji Jha ([email protected])

Software Developer, MySQL Replication Team

2015

Page 2: FOSSASIA 2015: MySQL Group Replication

Safe Harbor Statement

The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. | 2

Page 3: FOSSASIA 2015: MySQL Group Replication

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. | 3

Program Agenda

MySQL Group Replication Background

Zoom in: Major Building Blocks

Zoom in: The Complete Stack

Considerations

Summary

1

2

3

4

5

Page 4: FOSSASIA 2015: MySQL Group Replication

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. | 4

Program Agenda

MySQL Group Replication Background

Zoom in: Major Building Blocks

Zoom in: The Complete Stack

Considerations

Summary

1

2

3

4

5

Page 5: FOSSASIA 2015: MySQL Group Replication

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

MySQL Replication

MySQL Master server— Changes data.— Sends changes to Slave.

MySQL Slave server— Receives changes from master.— Applies received changes to database.

MASTER SLAVE

Page 6: FOSSASIA 2015: MySQL Group Replication

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

MySQL (Asynchronous) Replication

Native MySQL Replication: Asynchronous— Master executes transaction (T1), commits, ACKs to app, sends to slave.

Fast. Changes might be lost if master dies.

Master

Slave

Page 7: FOSSASIA 2015: MySQL Group Replication

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

MySQL Semi-synchronous Replication

Master

Slave

MySQL-5.5 introduced semi-synchronous replication as a plugin.— Extra synchronization step between master and slave.

Point of synchronization configurable on time axis.— Master executes, (slave receives, master commits), master ACKs to app.

Slower: Master waits for slave. Less risk for lost updates.

Page 8: FOSSASIA 2015: MySQL Group Replication

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

MySQL Group Replication

Recently: Labs preview of Group Replication based on MySQL-5.7— Multi-master update everywhere replication protocol.— A set of servers that interact via message passing.— (Virtually) synchronous architecture.

Master

Master

Master

Page 9: FOSSASIA 2015: MySQL Group Replication

9Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

MySQL Group Replication

What is MySQL Group Replication ?

“Multi-master update everywhere replication plugin for MySQLwith built-in automatic distributed recovery, conflict detectionand group membership.”

What does the MySQL Group Replication plugin do for the user?— Enables update everywhere setup.— Provides fault tolerance.

Servers can leave (voluntary or involuntary) and join at any time. The group self adjusts without any human intervention.

— Automates group reconfiguration (handling of crashes, failures, re-connects).— Implements a replicated Database State Machine.

Page 10: FOSSASIA 2015: MySQL Group Replication

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

M M M M M

Write Clients

MySQL ReplicationEnvironment

MySQL Group Replication

Page 11: FOSSASIA 2015: MySQL Group Replication

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

M M M M M

Update ...

Application issues an update.

Group-Based Replication Plugin

Page 12: FOSSASIA 2015: MySQL Group Replication

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

M M M M M

ReplicationEvents

Application issues an update.

Master executes and multi/broadcasts the update to the other servers.

Group-Based Replication Plugin

Page 13: FOSSASIA 2015: MySQL Group Replication

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

M M M M M

Application issues an update.

Master executes and multi/broadcasts the update to the other servers.

Servers receive same transaction in the same order and check for conflicts.

Group-Based Replication Plugin

Page 14: FOSSASIA 2015: MySQL Group Replication

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

M M M M M

Application issues an update.

Master executes and multi/broadcasts the update to the other servers.

Servers receive same transaction in the same order and check for conflicts.

All servers, independently, decide to commit the transaction – no conflicts.

Group-Based Replication Plugin

Page 15: FOSSASIA 2015: MySQL Group Replication

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

Application issues an update.

Master executes and multi/broadcasts the update to the other servers.

Servers receive same transaction in the same order and check for conflicts.

All servers, independently, decide to commit the transaction – no conflicts.

Originating master replies to the application.

M M M M M

Group-Based Replication Plugin

Page 16: FOSSASIA 2015: MySQL Group Replication

16Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

MySQL Group Replication is...… built on top of proven technology!

— Shares a lot of MySQL Replication infrastructure.— Multi-Master approach to replication.

… very interesting, architecturally speaking!— The plugin registers as listener to server events.— Decoupled from the server core.— Provides further decoupling from the communication infrastructure.

… built on reusable components!— Layered implementation approach.— Interface driven development.

Page 17: FOSSASIA 2015: MySQL Group Replication

17Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

MySQL Group Replication Provides...… Automatic distributed server recovery!

— Server that joins the group will automatically synchronize with the others.— If a server leaves the group, the others will automatically be informed.

… Multi-master Update Everywhere!— Any two transactions on different servers can write to the same tuple. Conflicts

will be detected.

… MySQL/InnoDB look & feel!— Load the plugin and start replicating...— Monitor group replication stats through Performance Schema tables.

Page 18: FOSSASIA 2015: MySQL Group Replication

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. | 18

Program Agenda

MySQL Group Replication Background

Zoom in: Major Building Blocks

Zoom in: The Complete Stack

Considerations

Summary

1

2

3

4

5

Page 19: FOSSASIA 2015: MySQL Group Replication

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

M M M M MCom. API

ReplicationPlugin

API

MySQLServer

Group Comm.System (Corosync)Group Comm.

System (Corosync)

Zoom in: Major Building Blocks

Page 20: FOSSASIA 2015: MySQL Group Replication

20Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

Com. API

ReplicationPlugin

API

MySQLServer

Zoom in: Major Building Blocks

Server calls into the plugin through a generic interface.

— Server is Starting Recovering Ready to accept connections About to commit a transaction etc..

Plugin interacts with the server through a generic interface.

— Instruct server to Commit or abort the ongoing transaction Queue transaction in relay log etc..Group Comm.

System (Corosync)Group Comm.

System (Corosync)

Page 21: FOSSASIA 2015: MySQL Group Replication

21Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

Com. API

ReplicationPlugin

API

MySQLServer

Zoom in: Major Building Blocks

The plugin is responsible for — Maintaining distributed execution context.— Detecting conflicts.— Handling distributed recovery.

Detect membership changes. Donate state if needed. Collect state if needed.

— Receiving and handling transactions from other replicas.

— Sending transactions to other replicas.— Deciding the fate of on-going transactions.

Group Comm.System (Corosync)Group Comm.

System (Corosync)

Page 22: FOSSASIA 2015: MySQL Group Replication

22Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

Com. API

ReplicationPlugin

API

MySQLServer

Zoom in: Major Building Blocks

The communication API is responsible for:— Decouples the underlaying communication

system from rest of the plugin.— Mapping the interface to a specific

communication toolkit. The Group Replication labs release uses a

corosync binding.

Group Comm.System (Corosync)Group Comm.

System (Corosync)

Page 23: FOSSASIA 2015: MySQL Group Replication

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. | 23

Program Agenda

MySQL Group Replication Background

Zoom in: Major Building Blocks

Zoom in: The Complete Stack

Considerations

Summary

1

2

3

4

5

Page 24: FOSSASIA 2015: MySQL Group Replication

24Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

API

ReplicationPlugin

API

MySQLServer

Zoom in: The Complete StackPerformance Schema Tables: Monitoring

MySQL

APIs: Lifecycle / Capture / Applier

InnoDB

Replication Protocol

Group Comm. API

Corosync

Network

Plu

ginCapture Applier

ConflictsHandler

Group Comm.System (Corosync)Group Comm.

System (Corosync)

Group Comm. Binding

Recovery

Page 25: FOSSASIA 2015: MySQL Group Replication

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. | 25

Program Agenda

MySQL Group Replication Background

Zoom in: Major Building Blocks

Zoom in: The Complete Stack

Considerations

Summary

1

2

3

4

5

Page 26: FOSSASIA 2015: MySQL Group Replication

26Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

Current MySQL Group Replication Limitations

Only supports transactional engines (InnoDB).

Limited DDL support. Don't execute concurrently with DML.

Primary Key required on every table.

Requires global transaction identifiers turned on.

Optimistic execution: transactions may abort on COMMIT due to conflicts with concurrent transactions on other sites.

Upper limit on transaction payload size (due to corosync).

Page 27: FOSSASIA 2015: MySQL Group Replication

27Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

Optimistic Multi-Master Update Everywhere Observations

Workload with hotspots => higher abort rates if executed concurrently at different replicas.— Any two transactions that have high probability to conflict should execute on

the same replica.

Better suited for low latency, high-bandwidth networks – LAN.— Communication latency adds up to the execution time.— If a replica is “far” away from the rest of the group (in terms of latency), it has

more chances that its transactions are aborted during the conflict detection phase.

Large transactions are more likely to exhibit higher conflict.— Smaller concurrent transactions may commit first thus rendering large

transactions write-sets obsoletes.

Page 28: FOSSASIA 2015: MySQL Group Replication

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. | 28

Program Agenda

MySQL Group Replication Background

Zoom in: Major Building Blocks

Zoom in: The Complete Stack

Considerations

Summary

1

2

3

4

5

Page 29: FOSSASIA 2015: MySQL Group Replication

29Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

SummaryTrendy

— Great technology for deployments where elasticity is a requirement, such as cloud based infrastructures

Integrated— It is integrated with the server core through a well defined API.— It is integrated with GTIDs, row based replication.— It is integrated with performance schema tables.

Autonomic and Operations Friendly— It is self-healing: no admin overhead for handling server fail-overs.— Provides fault-tolerance, enables multi-master update everywhere and a

dependable MySQL service.

Page 30: FOSSASIA 2015: MySQL Group Replication

30Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

SummaryTrendy

— Great technology for deployments where elasticity is a requirement, such as cloud based infrastructures

Integrated— It is integrated with the server core through a well defined API.— It is integrated with GTIDs, row based replication.— It is integrated with performance schema tables.

Autonomic and Operations Friendly— It is self-healing: no admin overhead for handling server fail-overs.— Provides fault-tolerance, enables multi-master update everywhere and a

dependable MySQL service.

MySQL Group Replication is all that... and more! Give it a try and send us your feedback. You can be part of this story too with your suggestions and

feature requests!

Page 31: FOSSASIA 2015: MySQL Group Replication

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FOSSASIA 2015 | Singapore, 14 th March, 2015. |

Next Steps: Read about Group Replication

Stay tuned to our blogs from the developers themselves.http://mysqlhighavailability.com/tag/mysql-group-replication/

Try this out.http://labs.mysql.com/

Suggest features, find bugs and please do get back to us.http://bugs.mysql.com/

Page 32: FOSSASIA 2015: MySQL Group Replication