SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
FOSDEM 2012




                                 Replication features of 2011
                                              What they were
                                              How to get them
                                              How to use them



                                                                    Sergey Petrunya
                                                                    MariaDB


Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
MySQL Replication in 2011: overview

Notable events, chronologically:

● MySQL 5.5 GA (Dec 2010)
● MariaDB 5.3 (Beta in June, RC in December)


   ●Group commit


● Replication listener


● MySQL 5.6 MS releases (April, October,

  December)

                                                                    2   14:46:17
Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
MySQL 5.5
                                                                    merged to
 MySQL 5.5                                                                      Percona Server 5.5
 ●   Semi-synchronous replication plugin
     (delay reporting the commit to client until it is in the relay log of some slave)

 ●   Slave fsync tuning (sync_relay_log_info, sync_master_info, sync_relay_log)

 ●   Automatic relay log recovery (--relay-log-recovery=1)

 ●   Replication Heartbeat (CHANGE MASTER SET master_heartbeat_period=)

 ●   Per-server filtering (CHANGE MASTER … IGNORE_SERVER_IDS=)

 ●   RBR slave type conversions (--slave-type-conversions=ALL_{NON}_LOSSY)
 ●   Individual Log Flushing (FLUSH ERROR|RELAY|BINARY|GENERAL LOGS)

 ●   SHOW RELAYLOG EVENTS
                                                                                         3      14:46:18
Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
MariaDB 5.3

Releases
● 5.3.1 Beta- July 2011, 5.3.2 Beta – Oct 2011


● 5.3.3 RC – Dec 2011



                                                                    Percona Server 5.5
Replication features
● Group commit for binary log

● Annotations for RBR events
                                         MySQL 5.6
● Checksums for binlog events

● Enchancements for START TRANSACTION WITH

  CONSISTENT SNAPSHOT
● Optimized RBR for tables

  without primary key            Percona's patch
                                                                            4      14:46:18
Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
Group commit for binary log
●   To get the D in ACID, one needs
          ● InnoDB: innodb_flush_log_at_trx_commit=1
          ● Binlog: sync_binlog=1


●   When you have both ON, group commit doesn't work
          ●   ~200 transactions per second max

                                                                                               Another workload
                                                                          1600



                                                                          1400



                                                                          1200



                                                                          1000


                                                                                                                                  trx+binlog
                                                                    TPS
                                                                           800
                                                                                                                                  No-sync
                                                                                                                                  trx
                                                                           600



                                                                           400



                                                                           200



                                                                             0
                                                                                 0   20   40    60        80   100   120   140

                                                                                                Threads

                                                                                                               5                 14:46:18
Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
Group commit for binary log (2)
●   Transactional operation with enabled binlog
          1.Write transaction to InnoDB transaction log
          2.Write transaction to binlog
                    •   This is the actual commit
          3.Write a commit record to InnoDB.




                                                                    6   14:46:19
Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
Group commit for binary log (2)

 ●   Pre-group-commit way to ensure the same ordering:




                                                                    7   14:46:19
Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
Group commit for binary log (3)
 ●   Group commit:




 ●   Multiple implementations: Facebook, MariaDB, proposal by
     Oracle
 ●   All different, based on similar ideas:
           ● Get tickets when writing to the binlog
           ● Fix InnoDB commits in the same order they were done with binlog


           ● (Maybe) Split P3 into the “fix ordering” (fast) and write-out (slow)

             phases
                                                                        8           14:46:19
Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
Group commit for binary log
  ●   So far, MariaDB 5.3 has the best
            ●   Ported into Percona Server 5.5




                              Chart from “Group commit in MariaDB is fast” post by Mark Callaghan
                                                                                                    9   14:46:19
Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
MariaDB 5.3: Annotated RBR events

  Every RBR event is accompanied by its source query
  ● Master: --binlog_annotate_row_events

  ● Slave: --replicate-annotate-rows-events

MariaDB [test]> show binlog events in 'pslp.000299';
+-------------+-----+---------------+-----------+-------------+-------------------------------------------------+
| Log_name    | Pos | Event_type    | Server_id | End_log_pos | Info                                            |
+-------------+-----+---------------+-----------+-------------+-------------------------------------------------+
| pslp.000299 |   4 | Format_desc   |         1 |         245 | Server ver: 5.3.4-MariaDB-rc-log, Binlog ver: 4 |
| pslp.000299 | 245 | Query         |         1 |         313 | BEGIN                                           |
| pslp.000299 | 313 | Annotate_rows |         1 |         379 | /* app1 */ insert into t1 values('foo'),('bar') |
| pslp.000299 | 379 | Table_map     |         1 |         422 | table_id: 15 (test.t1)                          |
| pslp.000299 | 422 | Write_rows    |         1 |         461 | table_id: 15 flags: STMT_END_F                  |
| pslp.000299 | 461 | Query         |         1 |         530 | COMMIT                                          |
| pslp.000299 | 530 | Query         |         1 |         598 | BEGIN                                           |
| pslp.000299 | 598 | Annotate_rows |         1 |         664 | /* app2 */ update t1 set a='test' where a='foo' |
| pslp.000299 | 664 | Table_map     |         1 |         707 | table_id: 15 (test.t1)                          |
| pslp.000299 | 707 | Update_rows   |         1 |         759 | table_id: 15 flags: STMT_END_F                  |
+-------------+-----+---------------+-----------+-------------+-------------------------------------------------+


 # at 379
 # at 422
 #120203 16:25:11 server id                1    end_log_pos 379   Annotate_rows:
 #Q> /* app1 */ insert into                t1   values('foo'),('bar')
 #120203 16:25:11 server id                1    end_log_pos 422   Table_map: `test`.`t1` mapped to number 15
 #120203 16:25:11 server id                1    end_log_pos 461   Write_rows: table id 15 flags: STMT_END_F

 BINLOG '
 J9IrTxMBAAAAKwAAAKYBAAAAAA8AAAAAAAEABHRlc3QAAnQxAAEPAgwAAQ==
                                                                                                               10   14:46:19
  Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
MySQL 5.6: annotated events, too

  ● Implementation is [naturally] very similar to MariaDB's. The
    user interface is different:
  ● Master: --binlog-rows-query-log-events


MySQL [test]> show binlog events;
+-------------+-----+-------------+-----------+-------------+---------------------------------------------------+
| Log_name    | Pos | Event_type | Server_id | End_log_pos | Info                                               |
+-------------+-----+-------------+-----------+-------------+---------------------------------------------------+
| pslp.000001 |   4 | Format_desc |         1 |         114 | Server ver: 5.6.5-m8-debug-log, Binlog ver: 4     |
| pslp.000001 | 114 | Query       |         1 |         215 | use `test`; create table t1 (a varchar(12))       |
| pslp.000001 | 215 | Query       |         1 |         283 | BEGIN                                             |
| pslp.000001 | 283 | Rows_query |          1 |         350 | # /* app1 */ insert into t1 values('foo'),('bar') |
| pslp.000001 | 350 | Table_map   |         1 |         393 | table_id: 66 (test.t1)                            |
| pslp.000001 | 393 | Write_rows |          1 |         432 | table_id: 66 flags: STMT_END_F                    |
| pslp.000001 | 432 | Xid         |         1 |         459 | COMMIT /* xid=5 */                                |
| pslp.000001 | 459 | Query       |         1 |         527 | BEGIN                                             |
| pslp.000001 | 527 | Rows_query |          1 |         594 | # /* app2 */ update t1 set a='test' where a='foo' |
| pslp.000001 | 594 | Table_map   |         1 |         637 | table_id: 66 (test.t1)                            |
| pslp.000001 | 637 | Update_rows |         1 |         678 | table_id: 66 flags: STMT_END_F                    |
| pslp.000001 | 678 | Xid         |         1 |         705 | COMMIT /* xid=6 */                                |
+-------------+-----+-------------+-----------+-------------+---------------------------------------------------+




                                                                                              11             14:46:20
 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
A compatibility problem

● MariaDB 5.3 added Annotate_rows event
● MySQL 5.6 added Rows_query event


● They are different events

          ● MariaDB 5.3 can't understand Rows_query
          ● MySQL 5.6 can't understand Annotate_rows


●    Seeing unknown event in binlog → error
          ●   (It is not safe to continue after you've skipped an unknown operation)

●    MySQL 5.6 will have a flag to mark “ignorable” binlog events
          ● We'll merge this to MariaDB
          ● This will make binary logs compatible again




                                                                        12        14:46:20
Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
Optimized RBR for tables with no PK

 ●   An RBR event is essentially something like this:
     with table
         $tbl=`dbname.tablename` (col1 INT, col2 CHAR(N),...)
     do
         delete in $tbl row with (col1,col2) = (10, 'foo')

●    Execution before MariaDB 5.3
          ●   Use the *first* index to find records
                    ● If the table has PRIMARY KEY is present, it will be the first (OK)
                    ● If there is no PK, may end up using poor index

                              ●   If it is an FT index, replication stops with error
●    In MariaDB 5.3
          1. If there is a PRIMARY KEY, use it
          2. Otherwise, use first UNIQUE index w/o NULLs
          3. Otherwise, use the most-selective non-fulltext index
                                                                                       13   14:46:20
Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
MySQL 5.6

●    Crash-safe slave
          ●   replication info tables
●    Crash-safe master
          ●   binary log recovery
● Replication event checksums
● Time delayed replication

● Optimized row-based logging

          ●   --binlog_row_image={full,minimal,noblob}
                                                                    MariaDB 5.3
● Informational log events
● Remote backup of binary logs


● Server UUIDs

          ●   Replication topology detection
●    Parallel event execution on slave
                                                                       14         14:46:20
Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
Parallel event execution: background

 Slave SQL thread algorithm:
  while (get next next event from relay log) {
    execute event;
  }

Problems
● Cannot use multiple CPUs

● Cannot enqueue multiple disk requests


=> slave may be unable to keep up with the master




                                                                    15   14:46:20
Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
Solution#1: Parallel slave

 The idea: execute binlog events in parallel




 Problems to address:
 ● Out-of-order event execution must produce the same result

 ● Slave may be in a state that never existed on the master

           ●   Including being in this state after the crash
                                                                    16   14:46:20
Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
MySQL 5.6's parallel slave

 Basic idea: partition events by hash (db_name)

●   Changes to different db's can be ran
    out-of-order
        ●   This should be ok for your application, too
●   Exec_Master_Log_Pos is a low-
    watermark now
        ●   Slave keeps track of what was commited
            above the watermark and will use it for
            recovery
                                                                    (picture from Lars Thallman's OSCON 2011 talk)


The main problem
 ● Un-even distribution of load between workers

 ● A frequent case: most of updates are in one huge table



                                                                                              17                 14:46:20
Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
Alternate approach #1: pre-heating

IO-bound SQL thread can be made faster by
● Pre-read relay log

● Convert UPDATEs/DELETEs to SELECTs


● Execute the SELECTs

          ● Will cause relevant pages be pre-loaded into buffer pool
          ● Can be done in parallel




●    First implementation: mk-slave-prefetch
          ● Written in Perl
          ● Baron Schwartz (author): “Don't use it unless you're Facebook”




●    Second implementation
          ●   “Replication Booster” by Yoshinori Matsunobu

                                                                       18    14:46:20
Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
Replication booster

http://yoshinorimatsunobu.blogspot.com/2011/10/making­slave­pre­fetching­work­better.html

 Replication booster
 ● Written in C++ using mysql-replication-listener API


 ● Uses regexps to convert UPDATEs/DELETEs to SELECTs

 ● Doesn't support RBR events

 ● Uses multiple threads to parse/re-write binlog events


 ● Keeps itself 0..3 sec ahead of the SQL thread




 Performance improvements
 ● Benchmark: from 1779 updates/sec to 5,418 updates/sec


 ● 30..300% improvement on various slaves

 ● No negative impact when all data is already in cache


                                                                        19         14:46:20
 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
Alternative approach #2: group commit

 ● A possible future development in MariaDB.
 ● Basic idea: commits in a group do not conflict

           ●   They were in “Prepare” stage together




 ●   Hence, commits from the same group can be done out-of-
     order, in parallel

                                                                    20   14:46:20
Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
Alternative approach #2: group commit (2)


 ● How does the slave know
   which commits were in a
   group?
 ● Master should write markers

   into the binlog

●    Pro
          ● Can be better than hash(db_name) approach of MySQL 5.6
          ● Especially for the “all updates hit one-big-table” case


●    Contra
          ●   Grouping in binlog depends on how much the master was loaded



                                                                    21       14:46:20
Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
2011 in replication

●   Performance improvements
       ● Group commit for the binary log (MariaDB 5.3, Percona 5.5)
       ● Multi-Threaded Slave (MySQL 5.6)


●   Row-Based Replication
       ● RBR event annotation (MariaDB 5.3, MySQL 5.6)
       ● binlog_row_image={full,minimal,noblob} (MySQL 5.6)


       ● Speedup for RBR of tables without PK (Percona~>MariaDB 5.3)


●   Safety
       ● Binlog checksums (MySQL 5.6 -> MariaDB 5.3)
       ● Crash-safe master, Crash-save slave (MySQL 5.6)


●   Pseudo-slaves
       ● launchpad.net/mysql-replication-listener
       ● mysqlbinlog --read-from-remote-server –raw (MySQL 5.6)


●   Misc
       ● Delayed replication (MySQL 5.6)
       ● START TRX WITH CONSISTENT SNAPSHOT (MariaDB 5.3)
                                                                      22   14:46:20
Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
Links

 Most of replication developers blog!

 ● http://www.mysqlperformanceblog.com
 ● http://www.facebook.com/MySQLatFacebook


 ● http://kristiannielsen.livejournal.com/


 ● http://mysqlmusings.blogspot.com/

 ● http://yoshinorimatsunobu.blogspot.com

 ● http://datacharmer.blogspot.com/

 ● http://d2-systems.blogspot.com/


 ● (hopefully didn't forget anyone)




                                                                    23   14:46:20
Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
Thanks!




                                                                    Q&A




                                                                          24   14:46:21
Notice: MySQL is a registered trademark of Sun Microsystems, Inc.

Weitere ähnliche Inhalte

Was ist angesagt?

0888 learning-mysql
0888 learning-mysql0888 learning-mysql
0888 learning-mysqlsabir18
 
Basic MySQL Troubleshooting for Oracle Database Administrators
Basic MySQL Troubleshooting for Oracle Database AdministratorsBasic MySQL Troubleshooting for Oracle Database Administrators
Basic MySQL Troubleshooting for Oracle Database AdministratorsSveta Smirnova
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in ActionSveta Smirnova
 
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013Sergey Petrunya
 
Need for Speed: Mysql indexing
Need for Speed: Mysql indexingNeed for Speed: Mysql indexing
Need for Speed: Mysql indexingFromDual GmbH
 
Introduction into MySQL Query Tuning
Introduction into MySQL Query TuningIntroduction into MySQL Query Tuning
Introduction into MySQL Query TuningSveta Smirnova
 
Playing with the CONNECT storage engine
Playing with the CONNECT storage enginePlaying with the CONNECT storage engine
Playing with the CONNECT storage engineFederico Razzoli
 
Percona Live 2012PPT: introduction-to-mysql-replication
Percona Live 2012PPT: introduction-to-mysql-replicationPercona Live 2012PPT: introduction-to-mysql-replication
Percona Live 2012PPT: introduction-to-mysql-replicationmysqlops
 
Introducing new SQL syntax and improving performance with preparse Query Rewr...
Introducing new SQL syntax and improving performance with preparse Query Rewr...Introducing new SQL syntax and improving performance with preparse Query Rewr...
Introducing new SQL syntax and improving performance with preparse Query Rewr...Sveta Smirnova
 
New features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in actionNew features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in actionSveta Smirnova
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingSveta Smirnova
 
Why Use EXPLAIN FORMAT=JSON?
 Why Use EXPLAIN FORMAT=JSON?  Why Use EXPLAIN FORMAT=JSON?
Why Use EXPLAIN FORMAT=JSON? Sveta Smirnova
 
MySQL Multi-Source Replication for PL2016
MySQL Multi-Source Replication for PL2016MySQL Multi-Source Replication for PL2016
MySQL Multi-Source Replication for PL2016Wagner Bianchi
 
Character Encoding - MySQL DevRoom - FOSDEM 2015
Character Encoding - MySQL DevRoom - FOSDEM 2015Character Encoding - MySQL DevRoom - FOSDEM 2015
Character Encoding - MySQL DevRoom - FOSDEM 2015mushupl
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingSveta Smirnova
 
PostgreSQL Write-Ahead Log (Heikki Linnakangas)
PostgreSQL Write-Ahead Log (Heikki Linnakangas) PostgreSQL Write-Ahead Log (Heikki Linnakangas)
PostgreSQL Write-Ahead Log (Heikki Linnakangas) Ontico
 

Was ist angesagt? (20)

0888 learning-mysql
0888 learning-mysql0888 learning-mysql
0888 learning-mysql
 
Basic MySQL Troubleshooting for Oracle Database Administrators
Basic MySQL Troubleshooting for Oracle Database AdministratorsBasic MySQL Troubleshooting for Oracle Database Administrators
Basic MySQL Troubleshooting for Oracle Database Administrators
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in Action
 
MySQL 5.5 Guide to InnoDB Status
MySQL 5.5 Guide to InnoDB StatusMySQL 5.5 Guide to InnoDB Status
MySQL 5.5 Guide to InnoDB Status
 
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
 
Need for Speed: Mysql indexing
Need for Speed: Mysql indexingNeed for Speed: Mysql indexing
Need for Speed: Mysql indexing
 
Introduction into MySQL Query Tuning
Introduction into MySQL Query TuningIntroduction into MySQL Query Tuning
Introduction into MySQL Query Tuning
 
Playing with the CONNECT storage engine
Playing with the CONNECT storage enginePlaying with the CONNECT storage engine
Playing with the CONNECT storage engine
 
MySQL and MariaDB Backups
MySQL and MariaDB BackupsMySQL and MariaDB Backups
MySQL and MariaDB Backups
 
MariaDB Temporal Tables
MariaDB Temporal TablesMariaDB Temporal Tables
MariaDB Temporal Tables
 
Percona Live 2012PPT: introduction-to-mysql-replication
Percona Live 2012PPT: introduction-to-mysql-replicationPercona Live 2012PPT: introduction-to-mysql-replication
Percona Live 2012PPT: introduction-to-mysql-replication
 
MySQL 5.1 and beyond
MySQL 5.1 and beyondMySQL 5.1 and beyond
MySQL 5.1 and beyond
 
Introducing new SQL syntax and improving performance with preparse Query Rewr...
Introducing new SQL syntax and improving performance with preparse Query Rewr...Introducing new SQL syntax and improving performance with preparse Query Rewr...
Introducing new SQL syntax and improving performance with preparse Query Rewr...
 
New features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in actionNew features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in action
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
 
Why Use EXPLAIN FORMAT=JSON?
 Why Use EXPLAIN FORMAT=JSON?  Why Use EXPLAIN FORMAT=JSON?
Why Use EXPLAIN FORMAT=JSON?
 
MySQL Multi-Source Replication for PL2016
MySQL Multi-Source Replication for PL2016MySQL Multi-Source Replication for PL2016
MySQL Multi-Source Replication for PL2016
 
Character Encoding - MySQL DevRoom - FOSDEM 2015
Character Encoding - MySQL DevRoom - FOSDEM 2015Character Encoding - MySQL DevRoom - FOSDEM 2015
Character Encoding - MySQL DevRoom - FOSDEM 2015
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
 
PostgreSQL Write-Ahead Log (Heikki Linnakangas)
PostgreSQL Write-Ahead Log (Heikki Linnakangas) PostgreSQL Write-Ahead Log (Heikki Linnakangas)
PostgreSQL Write-Ahead Log (Heikki Linnakangas)
 

Ähnlich wie Fosdem2012 replication-features-of-2011

Scaling mysql with python (and Docker).
Scaling mysql with python (and Docker).Scaling mysql with python (and Docker).
Scaling mysql with python (and Docker).Roberto Polli
 
Replication features, technologies and 3rd party Extinction
Replication features, technologies and 3rd party ExtinctionReplication features, technologies and 3rd party Extinction
Replication features, technologies and 3rd party ExtinctionBen Mildren
 
介绍 Percona 服务器 XtraDB 和 Xtrabackup
介绍 Percona 服务器 XtraDB 和 Xtrabackup介绍 Percona 服务器 XtraDB 和 Xtrabackup
介绍 Percona 服务器 XtraDB 和 XtrabackupYUCHENG HU
 
M|18 How Facebook Migrated to MyRocks
M|18 How Facebook Migrated to MyRocksM|18 How Facebook Migrated to MyRocks
M|18 How Facebook Migrated to MyRocksMariaDB plc
 
User Camp High Availability Presentation
User Camp High Availability PresentationUser Camp High Availability Presentation
User Camp High Availability Presentationsankalita chakraborty
 
MySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitationsMySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitationsJean-François Gagné
 
Using The Mysql Binary Log As A Change Stream
Using The Mysql Binary Log As A Change StreamUsing The Mysql Binary Log As A Change Stream
Using The Mysql Binary Log As A Change StreamLuís Soares
 
Percona 服务器与 XtraDB 存储引擎
Percona 服务器与 XtraDB 存储引擎Percona 服务器与 XtraDB 存储引擎
Percona 服务器与 XtraDB 存储引擎YUCHENG HU
 
MySQL Replication Update -- Zendcon 2016
MySQL Replication Update -- Zendcon 2016MySQL Replication Update -- Zendcon 2016
MySQL Replication Update -- Zendcon 2016Dave Stokes
 
MySQL Replication Overview -- PHPTek 2016
MySQL Replication Overview -- PHPTek 2016MySQL Replication Overview -- PHPTek 2016
MySQL Replication Overview -- PHPTek 2016Dave Stokes
 
MySQL/MariaDB Parallel Replication: inventory, use-case and limitations
MySQL/MariaDB Parallel Replication: inventory, use-case and limitationsMySQL/MariaDB Parallel Replication: inventory, use-case and limitations
MySQL/MariaDB Parallel Replication: inventory, use-case and limitationsJean-François Gagné
 
Percona Server for MySQL 8.0 @ Percona Live 2019
Percona Server for MySQL 8.0 @ Percona Live 2019Percona Server for MySQL 8.0 @ Percona Live 2019
Percona Server for MySQL 8.0 @ Percona Live 2019Laurynas Biveinis
 
MySQL Replication Basics -Ohio Linux Fest 2016
MySQL Replication Basics -Ohio Linux Fest 2016MySQL Replication Basics -Ohio Linux Fest 2016
MySQL Replication Basics -Ohio Linux Fest 2016Dave Stokes
 
PL22 - Backup and Restore Performance.pptx
PL22 - Backup and Restore Performance.pptxPL22 - Backup and Restore Performance.pptx
PL22 - Backup and Restore Performance.pptxVinicius M Grippa
 
Faster, better, stronger: The new InnoDB
Faster, better, stronger: The new InnoDBFaster, better, stronger: The new InnoDB
Faster, better, stronger: The new InnoDBMariaDB plc
 
Best practices for MySQL High Availability Tutorial
Best practices for MySQL High Availability TutorialBest practices for MySQL High Availability Tutorial
Best practices for MySQL High Availability TutorialColin Charles
 
Redo log improvements MYSQL 8.0
Redo log improvements MYSQL 8.0Redo log improvements MYSQL 8.0
Redo log improvements MYSQL 8.0Mydbops
 
Hardware assited x86 emulation on godson 3
Hardware assited x86 emulation on godson 3Hardware assited x86 emulation on godson 3
Hardware assited x86 emulation on godson 3Takuya ASADA
 

Ähnlich wie Fosdem2012 replication-features-of-2011 (20)

Scaling mysql with python (and Docker).
Scaling mysql with python (and Docker).Scaling mysql with python (and Docker).
Scaling mysql with python (and Docker).
 
Replication features, technologies and 3rd party Extinction
Replication features, technologies and 3rd party ExtinctionReplication features, technologies and 3rd party Extinction
Replication features, technologies and 3rd party Extinction
 
介绍 Percona 服务器 XtraDB 和 Xtrabackup
介绍 Percona 服务器 XtraDB 和 Xtrabackup介绍 Percona 服务器 XtraDB 和 Xtrabackup
介绍 Percona 服务器 XtraDB 和 Xtrabackup
 
M|18 How Facebook Migrated to MyRocks
M|18 How Facebook Migrated to MyRocksM|18 How Facebook Migrated to MyRocks
M|18 How Facebook Migrated to MyRocks
 
MySQL Replication
MySQL ReplicationMySQL Replication
MySQL Replication
 
User Camp High Availability Presentation
User Camp High Availability PresentationUser Camp High Availability Presentation
User Camp High Availability Presentation
 
MySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitationsMySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitations
 
Using The Mysql Binary Log As A Change Stream
Using The Mysql Binary Log As A Change StreamUsing The Mysql Binary Log As A Change Stream
Using The Mysql Binary Log As A Change Stream
 
Percona 服务器与 XtraDB 存储引擎
Percona 服务器与 XtraDB 存储引擎Percona 服务器与 XtraDB 存储引擎
Percona 服务器与 XtraDB 存储引擎
 
MySQL Replication Update -- Zendcon 2016
MySQL Replication Update -- Zendcon 2016MySQL Replication Update -- Zendcon 2016
MySQL Replication Update -- Zendcon 2016
 
MySQL Replication Overview -- PHPTek 2016
MySQL Replication Overview -- PHPTek 2016MySQL Replication Overview -- PHPTek 2016
MySQL Replication Overview -- PHPTek 2016
 
MySQL/MariaDB Parallel Replication: inventory, use-case and limitations
MySQL/MariaDB Parallel Replication: inventory, use-case and limitationsMySQL/MariaDB Parallel Replication: inventory, use-case and limitations
MySQL/MariaDB Parallel Replication: inventory, use-case and limitations
 
Percona Server for MySQL 8.0 @ Percona Live 2019
Percona Server for MySQL 8.0 @ Percona Live 2019Percona Server for MySQL 8.0 @ Percona Live 2019
Percona Server for MySQL 8.0 @ Percona Live 2019
 
MySQL Replication Basics -Ohio Linux Fest 2016
MySQL Replication Basics -Ohio Linux Fest 2016MySQL Replication Basics -Ohio Linux Fest 2016
MySQL Replication Basics -Ohio Linux Fest 2016
 
PL22 - Backup and Restore Performance.pptx
PL22 - Backup and Restore Performance.pptxPL22 - Backup and Restore Performance.pptx
PL22 - Backup and Restore Performance.pptx
 
Faster, better, stronger: The new InnoDB
Faster, better, stronger: The new InnoDBFaster, better, stronger: The new InnoDB
Faster, better, stronger: The new InnoDB
 
Best practices for MySQL High Availability Tutorial
Best practices for MySQL High Availability TutorialBest practices for MySQL High Availability Tutorial
Best practices for MySQL High Availability Tutorial
 
Redo log improvements MYSQL 8.0
Redo log improvements MYSQL 8.0Redo log improvements MYSQL 8.0
Redo log improvements MYSQL 8.0
 
Hardware assited x86 emulation on godson 3
Hardware assited x86 emulation on godson 3Hardware assited x86 emulation on godson 3
Hardware assited x86 emulation on godson 3
 
MariaDB pres at LeMUG
MariaDB pres at LeMUGMariaDB pres at LeMUG
MariaDB pres at LeMUG
 

Mehr von Sergey Petrunya

New optimizer features in MariaDB releases before 10.12
New optimizer features in MariaDB releases before 10.12New optimizer features in MariaDB releases before 10.12
New optimizer features in MariaDB releases before 10.12Sergey Petrunya
 
MariaDB's join optimizer: how it works and current fixes
MariaDB's join optimizer: how it works and current fixesMariaDB's join optimizer: how it works and current fixes
MariaDB's join optimizer: how it works and current fixesSergey Petrunya
 
Improved histograms in MariaDB 10.8
Improved histograms in MariaDB 10.8Improved histograms in MariaDB 10.8
Improved histograms in MariaDB 10.8Sergey Petrunya
 
Improving MariaDB’s Query Optimizer with better selectivity estimates
Improving MariaDB’s Query Optimizer with better selectivity estimatesImproving MariaDB’s Query Optimizer with better selectivity estimates
Improving MariaDB’s Query Optimizer with better selectivity estimatesSergey Petrunya
 
JSON Support in MariaDB: News, non-news and the bigger picture
JSON Support in MariaDB: News, non-news and the bigger pictureJSON Support in MariaDB: News, non-news and the bigger picture
JSON Support in MariaDB: News, non-news and the bigger pictureSergey Petrunya
 
Optimizer Trace Walkthrough
Optimizer Trace WalkthroughOptimizer Trace Walkthrough
Optimizer Trace WalkthroughSergey Petrunya
 
ANALYZE for Statements - MariaDB's hidden gem
ANALYZE for Statements - MariaDB's hidden gemANALYZE for Statements - MariaDB's hidden gem
ANALYZE for Statements - MariaDB's hidden gemSergey Petrunya
 
Optimizer features in recent releases of other databases
Optimizer features in recent releases of other databasesOptimizer features in recent releases of other databases
Optimizer features in recent releases of other databasesSergey Petrunya
 
MariaDB 10.4 - что нового
MariaDB 10.4 - что новогоMariaDB 10.4 - что нового
MariaDB 10.4 - что новогоSergey Petrunya
 
Using histograms to get better performance
Using histograms to get better performanceUsing histograms to get better performance
Using histograms to get better performanceSergey Petrunya
 
MariaDB Optimizer - further down the rabbit hole
MariaDB Optimizer - further down the rabbit holeMariaDB Optimizer - further down the rabbit hole
MariaDB Optimizer - further down the rabbit holeSergey Petrunya
 
Query Optimizer in MariaDB 10.4
Query Optimizer in MariaDB 10.4Query Optimizer in MariaDB 10.4
Query Optimizer in MariaDB 10.4Sergey Petrunya
 
Lessons for the optimizer from running the TPC-DS benchmark
Lessons for the optimizer from running the TPC-DS benchmarkLessons for the optimizer from running the TPC-DS benchmark
Lessons for the optimizer from running the TPC-DS benchmarkSergey Petrunya
 
MariaDB 10.3 Optimizer - where does it stand
MariaDB 10.3 Optimizer - where does it standMariaDB 10.3 Optimizer - where does it stand
MariaDB 10.3 Optimizer - where does it standSergey Petrunya
 
MyRocks in MariaDB | M18
MyRocks in MariaDB | M18MyRocks in MariaDB | M18
MyRocks in MariaDB | M18Sergey Petrunya
 
New Query Optimizer features in MariaDB 10.3
New Query Optimizer features in MariaDB 10.3New Query Optimizer features in MariaDB 10.3
New Query Optimizer features in MariaDB 10.3Sergey Petrunya
 
Histograms in MariaDB, MySQL and PostgreSQL
Histograms in MariaDB, MySQL and PostgreSQLHistograms in MariaDB, MySQL and PostgreSQL
Histograms in MariaDB, MySQL and PostgreSQLSergey Petrunya
 
Common Table Expressions in MariaDB 10.2
Common Table Expressions in MariaDB 10.2Common Table Expressions in MariaDB 10.2
Common Table Expressions in MariaDB 10.2Sergey Petrunya
 

Mehr von Sergey Petrunya (20)

New optimizer features in MariaDB releases before 10.12
New optimizer features in MariaDB releases before 10.12New optimizer features in MariaDB releases before 10.12
New optimizer features in MariaDB releases before 10.12
 
MariaDB's join optimizer: how it works and current fixes
MariaDB's join optimizer: how it works and current fixesMariaDB's join optimizer: how it works and current fixes
MariaDB's join optimizer: how it works and current fixes
 
Improved histograms in MariaDB 10.8
Improved histograms in MariaDB 10.8Improved histograms in MariaDB 10.8
Improved histograms in MariaDB 10.8
 
Improving MariaDB’s Query Optimizer with better selectivity estimates
Improving MariaDB’s Query Optimizer with better selectivity estimatesImproving MariaDB’s Query Optimizer with better selectivity estimates
Improving MariaDB’s Query Optimizer with better selectivity estimates
 
JSON Support in MariaDB: News, non-news and the bigger picture
JSON Support in MariaDB: News, non-news and the bigger pictureJSON Support in MariaDB: News, non-news and the bigger picture
JSON Support in MariaDB: News, non-news and the bigger picture
 
Optimizer Trace Walkthrough
Optimizer Trace WalkthroughOptimizer Trace Walkthrough
Optimizer Trace Walkthrough
 
ANALYZE for Statements - MariaDB's hidden gem
ANALYZE for Statements - MariaDB's hidden gemANALYZE for Statements - MariaDB's hidden gem
ANALYZE for Statements - MariaDB's hidden gem
 
Optimizer features in recent releases of other databases
Optimizer features in recent releases of other databasesOptimizer features in recent releases of other databases
Optimizer features in recent releases of other databases
 
MariaDB 10.4 - что нового
MariaDB 10.4 - что новогоMariaDB 10.4 - что нового
MariaDB 10.4 - что нового
 
Using histograms to get better performance
Using histograms to get better performanceUsing histograms to get better performance
Using histograms to get better performance
 
MariaDB Optimizer - further down the rabbit hole
MariaDB Optimizer - further down the rabbit holeMariaDB Optimizer - further down the rabbit hole
MariaDB Optimizer - further down the rabbit hole
 
Query Optimizer in MariaDB 10.4
Query Optimizer in MariaDB 10.4Query Optimizer in MariaDB 10.4
Query Optimizer in MariaDB 10.4
 
Lessons for the optimizer from running the TPC-DS benchmark
Lessons for the optimizer from running the TPC-DS benchmarkLessons for the optimizer from running the TPC-DS benchmark
Lessons for the optimizer from running the TPC-DS benchmark
 
MariaDB 10.3 Optimizer - where does it stand
MariaDB 10.3 Optimizer - where does it standMariaDB 10.3 Optimizer - where does it stand
MariaDB 10.3 Optimizer - where does it stand
 
MyRocks in MariaDB | M18
MyRocks in MariaDB | M18MyRocks in MariaDB | M18
MyRocks in MariaDB | M18
 
New Query Optimizer features in MariaDB 10.3
New Query Optimizer features in MariaDB 10.3New Query Optimizer features in MariaDB 10.3
New Query Optimizer features in MariaDB 10.3
 
MyRocks in MariaDB
MyRocks in MariaDBMyRocks in MariaDB
MyRocks in MariaDB
 
Histograms in MariaDB, MySQL and PostgreSQL
Histograms in MariaDB, MySQL and PostgreSQLHistograms in MariaDB, MySQL and PostgreSQL
Histograms in MariaDB, MySQL and PostgreSQL
 
Say Hello to MyRocks
Say Hello to MyRocksSay Hello to MyRocks
Say Hello to MyRocks
 
Common Table Expressions in MariaDB 10.2
Common Table Expressions in MariaDB 10.2Common Table Expressions in MariaDB 10.2
Common Table Expressions in MariaDB 10.2
 

Fosdem2012 replication-features-of-2011

  • 1. FOSDEM 2012 Replication features of 2011 What they were How to get them How to use them Sergey Petrunya MariaDB Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 2. MySQL Replication in 2011: overview Notable events, chronologically: ● MySQL 5.5 GA (Dec 2010) ● MariaDB 5.3 (Beta in June, RC in December) ●Group commit ● Replication listener ● MySQL 5.6 MS releases (April, October, December) 2 14:46:17 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 3. MySQL 5.5 merged to MySQL 5.5 Percona Server 5.5 ● Semi-synchronous replication plugin (delay reporting the commit to client until it is in the relay log of some slave) ● Slave fsync tuning (sync_relay_log_info, sync_master_info, sync_relay_log) ● Automatic relay log recovery (--relay-log-recovery=1) ● Replication Heartbeat (CHANGE MASTER SET master_heartbeat_period=) ● Per-server filtering (CHANGE MASTER … IGNORE_SERVER_IDS=) ● RBR slave type conversions (--slave-type-conversions=ALL_{NON}_LOSSY) ● Individual Log Flushing (FLUSH ERROR|RELAY|BINARY|GENERAL LOGS) ● SHOW RELAYLOG EVENTS 3 14:46:18 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 4. MariaDB 5.3 Releases ● 5.3.1 Beta- July 2011, 5.3.2 Beta – Oct 2011 ● 5.3.3 RC – Dec 2011 Percona Server 5.5 Replication features ● Group commit for binary log ● Annotations for RBR events MySQL 5.6 ● Checksums for binlog events ● Enchancements for START TRANSACTION WITH CONSISTENT SNAPSHOT ● Optimized RBR for tables without primary key Percona's patch 4 14:46:18 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 5. Group commit for binary log ● To get the D in ACID, one needs ● InnoDB: innodb_flush_log_at_trx_commit=1 ● Binlog: sync_binlog=1 ● When you have both ON, group commit doesn't work ● ~200 transactions per second max Another workload 1600 1400 1200 1000 trx+binlog TPS 800 No-sync trx 600 400 200 0 0 20 40 60 80 100 120 140 Threads 5 14:46:18 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 6. Group commit for binary log (2) ● Transactional operation with enabled binlog 1.Write transaction to InnoDB transaction log 2.Write transaction to binlog • This is the actual commit 3.Write a commit record to InnoDB. 6 14:46:19 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 7. Group commit for binary log (2) ● Pre-group-commit way to ensure the same ordering: 7 14:46:19 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 8. Group commit for binary log (3) ● Group commit: ● Multiple implementations: Facebook, MariaDB, proposal by Oracle ● All different, based on similar ideas: ● Get tickets when writing to the binlog ● Fix InnoDB commits in the same order they were done with binlog ● (Maybe) Split P3 into the “fix ordering” (fast) and write-out (slow) phases 8 14:46:19 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 9. Group commit for binary log ● So far, MariaDB 5.3 has the best ● Ported into Percona Server 5.5 Chart from “Group commit in MariaDB is fast” post by Mark Callaghan 9 14:46:19 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 10. MariaDB 5.3: Annotated RBR events Every RBR event is accompanied by its source query ● Master: --binlog_annotate_row_events ● Slave: --replicate-annotate-rows-events MariaDB [test]> show binlog events in 'pslp.000299'; +-------------+-----+---------------+-----------+-------------+-------------------------------------------------+ | Log_name | Pos | Event_type | Server_id | End_log_pos | Info | +-------------+-----+---------------+-----------+-------------+-------------------------------------------------+ | pslp.000299 | 4 | Format_desc | 1 | 245 | Server ver: 5.3.4-MariaDB-rc-log, Binlog ver: 4 | | pslp.000299 | 245 | Query | 1 | 313 | BEGIN | | pslp.000299 | 313 | Annotate_rows | 1 | 379 | /* app1 */ insert into t1 values('foo'),('bar') | | pslp.000299 | 379 | Table_map | 1 | 422 | table_id: 15 (test.t1) | | pslp.000299 | 422 | Write_rows | 1 | 461 | table_id: 15 flags: STMT_END_F | | pslp.000299 | 461 | Query | 1 | 530 | COMMIT | | pslp.000299 | 530 | Query | 1 | 598 | BEGIN | | pslp.000299 | 598 | Annotate_rows | 1 | 664 | /* app2 */ update t1 set a='test' where a='foo' | | pslp.000299 | 664 | Table_map | 1 | 707 | table_id: 15 (test.t1) | | pslp.000299 | 707 | Update_rows | 1 | 759 | table_id: 15 flags: STMT_END_F | +-------------+-----+---------------+-----------+-------------+-------------------------------------------------+ # at 379 # at 422 #120203 16:25:11 server id 1 end_log_pos 379 Annotate_rows: #Q> /* app1 */ insert into t1 values('foo'),('bar') #120203 16:25:11 server id 1 end_log_pos 422 Table_map: `test`.`t1` mapped to number 15 #120203 16:25:11 server id 1 end_log_pos 461 Write_rows: table id 15 flags: STMT_END_F BINLOG ' J9IrTxMBAAAAKwAAAKYBAAAAAA8AAAAAAAEABHRlc3QAAnQxAAEPAgwAAQ== 10 14:46:19 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 11. MySQL 5.6: annotated events, too ● Implementation is [naturally] very similar to MariaDB's. The user interface is different: ● Master: --binlog-rows-query-log-events MySQL [test]> show binlog events; +-------------+-----+-------------+-----------+-------------+---------------------------------------------------+ | Log_name | Pos | Event_type | Server_id | End_log_pos | Info | +-------------+-----+-------------+-----------+-------------+---------------------------------------------------+ | pslp.000001 | 4 | Format_desc | 1 | 114 | Server ver: 5.6.5-m8-debug-log, Binlog ver: 4 | | pslp.000001 | 114 | Query | 1 | 215 | use `test`; create table t1 (a varchar(12)) | | pslp.000001 | 215 | Query | 1 | 283 | BEGIN | | pslp.000001 | 283 | Rows_query | 1 | 350 | # /* app1 */ insert into t1 values('foo'),('bar') | | pslp.000001 | 350 | Table_map | 1 | 393 | table_id: 66 (test.t1) | | pslp.000001 | 393 | Write_rows | 1 | 432 | table_id: 66 flags: STMT_END_F | | pslp.000001 | 432 | Xid | 1 | 459 | COMMIT /* xid=5 */ | | pslp.000001 | 459 | Query | 1 | 527 | BEGIN | | pslp.000001 | 527 | Rows_query | 1 | 594 | # /* app2 */ update t1 set a='test' where a='foo' | | pslp.000001 | 594 | Table_map | 1 | 637 | table_id: 66 (test.t1) | | pslp.000001 | 637 | Update_rows | 1 | 678 | table_id: 66 flags: STMT_END_F | | pslp.000001 | 678 | Xid | 1 | 705 | COMMIT /* xid=6 */ | +-------------+-----+-------------+-----------+-------------+---------------------------------------------------+ 11 14:46:20 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 12. A compatibility problem ● MariaDB 5.3 added Annotate_rows event ● MySQL 5.6 added Rows_query event ● They are different events ● MariaDB 5.3 can't understand Rows_query ● MySQL 5.6 can't understand Annotate_rows ● Seeing unknown event in binlog → error ● (It is not safe to continue after you've skipped an unknown operation) ● MySQL 5.6 will have a flag to mark “ignorable” binlog events ● We'll merge this to MariaDB ● This will make binary logs compatible again 12 14:46:20 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 13. Optimized RBR for tables with no PK ● An RBR event is essentially something like this: with table $tbl=`dbname.tablename` (col1 INT, col2 CHAR(N),...) do delete in $tbl row with (col1,col2) = (10, 'foo') ● Execution before MariaDB 5.3 ● Use the *first* index to find records ● If the table has PRIMARY KEY is present, it will be the first (OK) ● If there is no PK, may end up using poor index ● If it is an FT index, replication stops with error ● In MariaDB 5.3 1. If there is a PRIMARY KEY, use it 2. Otherwise, use first UNIQUE index w/o NULLs 3. Otherwise, use the most-selective non-fulltext index 13 14:46:20 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 14. MySQL 5.6 ● Crash-safe slave ● replication info tables ● Crash-safe master ● binary log recovery ● Replication event checksums ● Time delayed replication ● Optimized row-based logging ● --binlog_row_image={full,minimal,noblob} MariaDB 5.3 ● Informational log events ● Remote backup of binary logs ● Server UUIDs ● Replication topology detection ● Parallel event execution on slave 14 14:46:20 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 15. Parallel event execution: background Slave SQL thread algorithm: while (get next next event from relay log) { execute event; } Problems ● Cannot use multiple CPUs ● Cannot enqueue multiple disk requests => slave may be unable to keep up with the master 15 14:46:20 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 16. Solution#1: Parallel slave The idea: execute binlog events in parallel Problems to address: ● Out-of-order event execution must produce the same result ● Slave may be in a state that never existed on the master ● Including being in this state after the crash 16 14:46:20 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 17. MySQL 5.6's parallel slave Basic idea: partition events by hash (db_name) ● Changes to different db's can be ran out-of-order ● This should be ok for your application, too ● Exec_Master_Log_Pos is a low- watermark now ● Slave keeps track of what was commited above the watermark and will use it for recovery (picture from Lars Thallman's OSCON 2011 talk) The main problem ● Un-even distribution of load between workers ● A frequent case: most of updates are in one huge table 17 14:46:20 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 18. Alternate approach #1: pre-heating IO-bound SQL thread can be made faster by ● Pre-read relay log ● Convert UPDATEs/DELETEs to SELECTs ● Execute the SELECTs ● Will cause relevant pages be pre-loaded into buffer pool ● Can be done in parallel ● First implementation: mk-slave-prefetch ● Written in Perl ● Baron Schwartz (author): “Don't use it unless you're Facebook” ● Second implementation ● “Replication Booster” by Yoshinori Matsunobu 18 14:46:20 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 19. Replication booster http://yoshinorimatsunobu.blogspot.com/2011/10/making­slave­pre­fetching­work­better.html Replication booster ● Written in C++ using mysql-replication-listener API ● Uses regexps to convert UPDATEs/DELETEs to SELECTs ● Doesn't support RBR events ● Uses multiple threads to parse/re-write binlog events ● Keeps itself 0..3 sec ahead of the SQL thread Performance improvements ● Benchmark: from 1779 updates/sec to 5,418 updates/sec ● 30..300% improvement on various slaves ● No negative impact when all data is already in cache 19 14:46:20 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 20. Alternative approach #2: group commit ● A possible future development in MariaDB. ● Basic idea: commits in a group do not conflict ● They were in “Prepare” stage together ● Hence, commits from the same group can be done out-of- order, in parallel 20 14:46:20 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 21. Alternative approach #2: group commit (2) ● How does the slave know which commits were in a group? ● Master should write markers into the binlog ● Pro ● Can be better than hash(db_name) approach of MySQL 5.6 ● Especially for the “all updates hit one-big-table” case ● Contra ● Grouping in binlog depends on how much the master was loaded 21 14:46:20 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 22. 2011 in replication ● Performance improvements ● Group commit for the binary log (MariaDB 5.3, Percona 5.5) ● Multi-Threaded Slave (MySQL 5.6) ● Row-Based Replication ● RBR event annotation (MariaDB 5.3, MySQL 5.6) ● binlog_row_image={full,minimal,noblob} (MySQL 5.6) ● Speedup for RBR of tables without PK (Percona~>MariaDB 5.3) ● Safety ● Binlog checksums (MySQL 5.6 -> MariaDB 5.3) ● Crash-safe master, Crash-save slave (MySQL 5.6) ● Pseudo-slaves ● launchpad.net/mysql-replication-listener ● mysqlbinlog --read-from-remote-server –raw (MySQL 5.6) ● Misc ● Delayed replication (MySQL 5.6) ● START TRX WITH CONSISTENT SNAPSHOT (MariaDB 5.3) 22 14:46:20 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 23. Links Most of replication developers blog! ● http://www.mysqlperformanceblog.com ● http://www.facebook.com/MySQLatFacebook ● http://kristiannielsen.livejournal.com/ ● http://mysqlmusings.blogspot.com/ ● http://yoshinorimatsunobu.blogspot.com ● http://datacharmer.blogspot.com/ ● http://d2-systems.blogspot.com/ ● (hopefully didn't forget anyone) 23 14:46:20 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.
  • 24. Thanks! Q&A 24 14:46:21 Notice: MySQL is a registered trademark of Sun Microsystems, Inc.