SUGGESTION #1 : Use Distribution Masters
A Distribution Master is a mysql slave with log-bin enabled, log-slave-updates enabled and contains only tables with the BLACKHOLE Storage Engine. You can apply replicate-do-db to the Distribution Master and create binary logs at the Distribution Master that contains only the DB schema(s) you want binlogged. In this way you reduce the size of outgoing binlogs from the Distribution Master.
You can setup a Distribution Master as follows:
- mysqldump your database(s) using --no-data option to generate a schema-only dump.
- Load the schema-only dump to the Distribution Master.
- Convert every table in the Distribution Master to the BLACKHOLE storage engine.
- Setup replication to the Distribution Master from a master with real data.
- Add replicate-do-db option(s) to /etc/my.cnf of the Distribution Master.
For steps 2 and 3 you could also edit the schema-only dump and replace ENGINE=MyISAM and ENGINE=InnoDB with ENGINE=BLACKHOLE and then load that edited schema-only dump into the Distribution Master.
In step 3 only, if you want to script the conversion of all MyISAM and InnoDB tables to BLACKHOLE in the Distribution Master, run the following query and output it to a text file:
mysql -h... -u... -p... -A --skip-column-names -e"SELECT CONCAT('ALTER TABLE ',table_schema,'.',table_name', ENGINE=BLACKHOLE;') BlackholeConversion FROM information_schema.tables WHERE table_schema NOT IN ('information_schema','mysql') AND engine <> 'BLACKHOLE'" > BlackholeMaker.sql
An added bonus to scripting the conversion of table to the BLACKHOLE storage engine is that MEMORY storage engine tables are converted as well. While MEMORY storage engine table do not take up disk space for data storage, it will take up memory. Converting MEMORY tables to BLACKHOLE will keep memory in the Distribution Master uncluttered.
As long as you do not send any DDL into the Distribution Master, you can transmit any DML (INSERT,UPDATE,DELETE) you so desire before letting clients replicate just the DB info they want.
I already wrote a post in another StackExchange site that discusses using a Distribution Master.
SUGGESTION #2 : Use Smaller Binary Logs and Relay Logs
If you set max_binlog_size to something ridiculously small, then binlogs can be collected and shipped out in smaller chunks. There is also a separate option to set the size of relay logs, max_relay_log_size. If max_relay_log_size = 0, it will default to whatever max_binlog_size is set to.
SUGGESTION #3 : Use Semisynchronous Replication (MySQL 5.5 only)
Setup your main database and multiple Distribution Masters as MySQL 5.5. Enable Semisynchronous Replication so that the main database can quickly ship binlogs to the Distribution Master. If ALL your slaves are Distribution Masters, you may not need Semisynchronous Replication or MySQL 5.5. If any of the slaves, other than Distribution Masters, have real data for reporting, high availability, passive standby or backup purposes, then go with MySQL 5.5 in conjunction with Semisynchronous Replication.
SUGGESTION #4 : Use Statement-Based Binary Logging NOT Row-Based
If an SQL statement updates multiple rows in a table, Statement-Based Binary Logging (SBBL) stores only the SQL statement. The same SQL statement using Row-Based Binary Logging (RBBL) will actual record the row change for each row. This makes it obvious that transmitting SQL statements will save space on binary logs doing SBBL over RBBL.
Another problem is using RBBL in conjunction with replicate-do-db where table name has the database prepended. This cannot be good for a slave, especially for a Distribution Master. Therefore, make sure all DML does not have a a database and a period in front of any table names.
You may find this surprising, but MySQL 5.1 may outperform MySQL 5.5 under certain circumstances.
Percona performed a bake-off among multiple releases of MySQL
- MySQL 4.1
- MySQL 5.0
- MySQL 5.1 (with built-in InnoDB)
- MySQL 5.1 with InnoDB-plugin
- MySQL 5.5
- MySQL 5.6
All tests were performed with MySQL unconfigured (In other words, no my.cnf was made). The results?
- MySQL 4.1 performs the best single-threaded
- MySQL 5.1 with InnoDB plug-in scales on multiple cores better than 5.1 InnoDB built, 5.5 and 5.6
If you want newer versions of MySQL to perform better, you must tune for it. In fact, I described in the DBA StackExchange the idea of performing a MySQL Bakeoff.
What do I mean tune for it?
In MySQL 5.5, there are new InnoDB options for utilizing more dedicated read threads, write threads, and overall I/O capacity. This can engage more CPUs in multicore servers. Left unconfigured, MySQL 5.5 would operate on the same level playing field, in most cases, as older versions of MySQL. Sometimes, it could perform worse.
Best Answer
There is no substitute of tuning MySQL. Left unconfigured, there are cases when even MySQL 4.1 outperforms MySQL 5.x on the same level playing field.
Here are my past posts on the subject
Oct 05, 2011
: Query runs a long time in some newer MySQL versionsNov 24, 2011
: Why mysql 5.5 slower than 5.1 (linux,using mysqlslap)Feb 08, 2012
: MySQL 5.5 perfomance (StackOverflow)Feb 22, 2012
: MySQL 5.1 vs MySQL 5.5 (5.1 twice as fast) (ServerFault)Jul 16, 2012
: decreased performance of stored procedure when migrated from mysql server 5.0 to 5.5Bottom Line
You should always use the most stable release of MySQL because there are just certain bug and features that are fixed that do not carry over to the next major release.
Note that
There are many exciting things that MySQL 5.5 features tuning for the following:
May 26, 2011
: About single threaded versus multithreaded databases performanceSep 12, 2011
: Possible to make MySQL use more than one core?Sep 20, 2011
: Multi cores and MySQL PerformanceAug 05, 2011
: Is MySQL Replication Affected by a High-Latency Interconnect?Oct 29, 2012
: Installing and enabling both master and slave semisynchronous plugins on same serverFeb 12, 2011
: How do you tune MySQL for a heavy InnoDB workload?