Load Testing Tools. for Troubleshooting MySQL Concurrency Issues. May, 23, 2018 Sveta Smirnova

Similar documents
Effective Testing for Live Applications. March, 29, 2018 Sveta Smirnova

MySQL Test Framework for Troubleshooting. February, 04, 2018 Sveta Smirnova

MySQL Performance Optimization and Troubleshooting with PMM. Peter Zaitsev, CEO, Percona Percona Technical Webinars 9 May 2018

MySQL usage of web applications from 1 user to 100 million. Peter Boros RAMP conference 2013

MySQL Performance Optimization and Troubleshooting with PMM. Peter Zaitsev, CEO, Percona

Troubleshooting Best Practices

What's new in MySQL 5.5? Performance/Scale Unleashed

Replication features of 2011

MyRocks in MariaDB. Sergei Petrunia MariaDB Tampere Meetup June 2018

Migrating to Aurora MySQL and Monitoring with PMM. Percona Technical Webinars August 1, 2018

Introduction to troubleshooting Basic techniques. Sveta Smirnova Principal Support Engineer March, 10, 2016

Scale out Read Only Workload by sharing data files of InnoDB. Zhai weixiang Alibaba Cloud

MySQL Schema Review 101

Improvements in MySQL 5.5 and 5.6. Peter Zaitsev Percona Live NYC May 26,2011

MyRocks deployment at Facebook and Roadmaps. Yoshinori Matsunobu Production Engineer / MySQL Tech Lead, Facebook Feb/2018, #FOSDEM #mysqldevroom

What s New in MySQL 5.7 Geir Høydalsvik, Sr. Director, MySQL Engineering. Copyright 2015, Oracle and/or its affiliates. All rights reserved.

MySQL Performance Tuning

Performance improvements in MySQL 5.5

XA Transactions in MySQL

TokuDB vs RocksDB. What to choose between two write-optimized DB engines supported by Percona. George O. Lorch III Vlad Lesin

MySQL 101. Designing effective schema for InnoDB. Yves Trudeau April 2015

MySQL 5.7 For Operational DBAs an Introduction. Peter Zaitsev, CEO, Percona February 16, 2016 Percona Technical Webinars

MySQL Storage Engines Which Do You Use? April, 25, 2017 Sveta Smirnova

Practical sysbench. Peter Boros Percona FOSDEM 2014

1Z Oracle. MySQL 5 Database Administrator Certified Professional Part I

Oracle 1Z MySQL 5.6 Database Administrator. Download Full Version :

MySQL Replication: What's New In MySQL 5.7 and MySQL 8. Luís Soares Software Development Director MySQL Replication

NoVA MySQL October Meetup. Tim Callaghan VP/Engineering, Tokutek

Introduction to pgbench

Oracle Exam 1z0-883 MySQL 5.6 Database Administrator Version: 8.0 [ Total Questions: 100 ]

InnoDB Scalability Limits. Peter Zaitsev, Vadim Tkachenko Percona Inc MySQL Users Conference 2008 April 14-17, 2008

The Care and Feeding of a MySQL Database for Linux Adminstrators. Dave Stokes MySQL Community Manager

Optimizing BOINC project databases

MySQL Performance Tuning 101

PolarDB. Cloud Native Alibaba. Lixun Peng Inaam Rana Alibaba Cloud Team

Everything You Need to Know About MySQL Group Replication

<Insert Picture Here> Boosting performance with MySQL partitions

Switching to Innodb from MyISAM. Matt Yonkovit Percona

1Z MySQL 5 Database Administrator Certified Professional Exam, Part II Exam.

MySQL 5.6: Advantages in a Nutshell. Peter Zaitsev, CEO, Percona Percona Technical Webinars March 6, 2013

MyRocks Engineering Features and Enhancements. Manuel Ung Facebook, Inc. Dublin, Ireland Sept th, 2017

Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12

Backup & Restore. Maximiliano Bubenick Sr Remote DBA

The Exciting MySQL 5.7 Replication Enhancements

Improving overall Robinhood performance for use on large-scale deployments Colin Faber

Why we re excited about MySQL 8

How To Rock with MyRocks. Vadim Tkachenko CTO, Percona Webinar, Jan

MariaDB: Community Driven SQL Server. Kristian Nielsen MariaDB developer Monty Program AB

Practical MySQL indexing guidelines

Innodb Performance Optimization

MySQL Performance Tuning

MySQL Schema Best Practices

<Insert Picture Here> New MySQL Enterprise Backup 4.1: Better Very Large Database Backup & Recovery and More!

Which technology to choose in AWS?

MySQL Performance Improvements

PhxSQL: A High-Availability & Strong-Consistency MySQL Cluster. Ming

MySQL Performance Troubleshooting

Load Data Fast! BILL KARWIN PERCONA LIVE OPEN SOURCE DATABASE CONFERENCE 2017

Testing and Verifying your MySQL Backup Strategy

MySQL Replication. Rick Golba and Stephane Combaudon April 15, 2015

Resolving and Preventing MySQL Downtime

Preventing and Resolving MySQL Downtime. Jervin Real, Michael Coburn Percona

SQL (and MySQL) Useful things I have learnt, borrowed and stolen

MySQL for Database Administrators Ed 3.1

Delegates must have a working knowledge of MariaDB or MySQL Database Administration.

Migrating To MySQL The Live Database Upgrade Guide

Percona XtraDB Cluster

InnoDB: Status, Architecture, and Latest Enhancements

Manual Mysql Query Cache Hit Rate 0

How to Fulfill the Potential of InnoDB's Performance and Scalability

MariaDB 10.3 vs MySQL 8.0. Tyler Duzan, Product Manager Percona

Creating a Best-in-Class Backup and Recovery System for Your MySQL Environment. Akshay Suryawanshi DBA Team Manager,

A Brief Introduction of TiDB. Dongxu (Edward) Huang CTO, PingCAP

XtraDB 5.7: Key Performance Algorithms. Laurynas Biveinis Alexey Stroganov Percona

Oracle 1Z0-882 Exam. Volume: 100 Questions. Question No: 1 Consider the table structure shown by this output: Mysql> desc city:

Chapter 4: Transaction Models

IT Certification Exams Provider! Weofferfreeupdateserviceforoneyear! h ps://

Writing High Performance SQL Statements. Tim Sharp July 14, 2014

<Insert Picture Here> Looking at Performance - What s new in MySQL Workbench 6.2

MySQL Database Scalability

Instant ALTER TABLE in MariaDB Marko Mäkelä Lead Developer InnoDB

The Hazards of Multi-writing in a Dual-Master Setup

V4BstS

MySQL 5.0 Certification Study Guide

ALTER TABLE Improvements in MARIADB Server. Marko Mäkelä Lead Developer InnoDB MariaDB Corporation

Course Outline. Performance Tuning and Optimizing SQL Databases Course 10987B: 4 days Instructor Led

ApsaraDB for RDS. Performance White Paper

MySQL for Database Administrators Ed 4

Drop Table If Exists Oracle Sql Command Not Properly Ended

What's New in MySQL 5.7?

Mysql Cluster Global Schema Lock

1Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12

MySQL 8.0 Performance: InnoDB Re-Design

ScaleArc Performance Benchmarking with sysbench

Covering indexes. Stéphane Combaudon - SQLI

[MS10987A]: Performance Tuning and Optimizing SQL Databases

Tired of MySQL Making You Wait? Alexander Rubin, Principal Consultant, Percona Janis Griffin, Database Evangelist, SolarWinds

Course Outline. SQL Server Performance & Tuning For Developers. Course Description: Pre-requisites: Course Content: Performance & Tuning.

MySQL Performance Tuning

MyRocks Storage Engine Status Update. Sergei Petrunia MariaDB Meetup New York February, 2018

Transcription:

Load Testing Tools for Troubleshooting MySQL Concurrency Issues May, 23, 2018 Sveta Smirnova

Introduction This is very personal webinar No intended use No best practices No QA-specific tools Real life don t generate queries Each customer has its own corner case Typical issues usually already found by QA team before first GA release date Creative by nature 2

Introduction This is very personal webinar I usually don t do benchmarks Unless have a reason to Performance Schema Benchmarks: OLTP RW 2

Introduction This is very personal webinar I usually don t do benchmarks I use load tools for reproducible scenarios Locking issues Crashes Custom slowdowns Replication issues Almost everything! 2

Introduction This is very personal webinar I usually don t do benchmarks I use load tools for reproducible scenarios It helps to fix them! 2

Few Examples Create binary log events 3. Connect to master, create database foo. 4. In parallel client start some load: mysqlslap --user=root --host=127.0.0.1 --port=13000 --create-schema=foo \ --query="create table if not exists t1(f1 int); insert into t1 values(1); \ drop table if exists t1;" -c 10 -i 10000 5. kill -9 slave process 6. Restart MTR in dirty mode:... 3

Few Examples 3 Generate parallel load 6. Run concurrent environment: sysbench --test=/home/sveta/src/sysbench/sysbench/tests/db/oltp.lua --mysql-engine-trx=yes \ --mysql-table-engine=innodb --oltp_table_size=1000 --oltp_tables_count=1 --mysql-user=root \ --mysql-host=127.0.0.1 --mysql-port=13000 --num-threads=8 --max-requests=1000 run 7. Turn OFF and ON slow log: mysql> set global slow_query_log=0; Query OK, 0 rows affected (0,09 sec) mysql> set global slow_query_log=1; Query OK, 0 rows affected (0,00 sec) 8. Now you have 4 descriptors:...

Few Examples Prepare data... --disable_query_log --let $i=10 while($i) { insert into cartest values (null, 1); --dec $i } --enable_query_log... 3

Table of Contents What Do I Do? Case Study: Slave Crash Why Do I Do Load Tests? Machines Which I Use Binaries Which I Use How Do I Scale Summary 4

What Do I Do?

Single Thread Issues: MySQL CLI Benchmarking tool by nature mysql> SELECT id, k FROM sbtest2 WHERE id=5014; +------+------+ id k +------+------+ 5014 3972 +------+------+ 1 row in set (0.16 sec) 6

Single Thread Issues: MySQL CLI 6 Benchmarking tool by nature mysql> SELECT id, k FROM sbtest2 WHERE id=5014; +------+------+ id k +------+------+ 5014 3972 +------+------+ 1 row in set (0.16 sec) Access to Status variables Engine status Performance Schema All internal troubleshooting tools

More than One Query: SHELL Shell is our friend $ while (true); do mysql -e "flush slow logs"; done... $ for i in seq 1 1 100000 ; \ do mysql -e "insert into t1(id, myfield) values \ ($i, cat /dev/urandom tr -dc A-Za-z0-9 head -c $(( RANDOM % (250-5 + 1 ) + 5 )) )"; \ done 7

More than One Query: SHELL Shell is our friend $ while (true); do mysql -e "flush slow logs"; done... $ for i in seq 1 1 100000 ; \ do mysql -e "insert into t1(id, myfield) values \ ($i, cat /dev/urandom tr -dc A-Za-z0-9 head -c $(( RANDOM % (250-5 + 1 ) + 5 )) )"; \ done Helps to Generate data Craft queries with slightly various parameters 7

More than One Query: SHELL 7 Shell is our friend $ while (true); do mysql -e "flush slow logs"; done... $ for i in seq 1 1 100000 ; \ do mysql -e "insert into t1(id, myfield) values \ ($i, cat /dev/urandom tr -dc A-Za-z0-9 head -c $(( RANDOM % (250-5 + 1 ) + 5 )) )"; \ done Helps to Generate data Craft queries with slightly various parameters Execute in multiple terminals To imitate concurrent load

Simple Tests: mysqlslap Queries without variations $ mysqlslap --concurrency=8 --number-of-queries=1000 \ --query="replace INTO mytest (ts, id, f1, f2, f3, f4) \ VALUES (now(), 1000*rand(), field text, 1000000*rand(), more text, 1)" \ --create-schema=test \ --pre-query="create TABLE test.mytest(ts TIMESTAMP, id INT NOT NULL PRIMARY KEY, \ f1 VARCHAR(255), f2 INT, f3 CHAR(20), f4 INT) ENGINE=INNODB" \ --post-query="drop TABLE test.mytest" Benchmark Average number of seconds to run all queries: 113.591 seconds Minimum number of seconds to run all queries: 113.591 seconds Maximum number of seconds to run all queries: 113.591 seconds Number of clients running queries: 8 Average number of queries per client: 125 8

Simple Tests: mysqlslap Queries without variations Supports auto-generated SQL $ time mysqlslap --concurrency=8 --auto-generate-sql --number-of-queries=100 Benchmark Average number of seconds to run all queries: 8.126 seconds Minimum number of seconds to run all queries: 8.126 seconds Maximum number of seconds to run all queries: 8.126 seconds Number of clients running queries: 8 Average number of queries per client: 12 real 1m37.932s user 0m0.032s sys 0m0.008s 8

Simple Tests: mysqlslap Queries without variations Supports auto-generated SQL Helpful for Simple query patterns When you need to imitate some activity Generate binary log events 8

Simple Tests: mysqlslap Queries without variations Supports auto-generated SQL Helpful for Should be used with care In auto-generate mode drops schema No matter if it has other tables of not! Always use option --no-drop Do not use on production databases 8

Standard and Custom Tests: SysBench Comes with standard OLTP tests $ sysbench --test=/home/sveta/src/sysbench/sysbench/tests/db/oltp.lua \ --mysql-engine-trx=yes --mysql-table-engine=innodb --oltp_table_size=10000 \ --oltp_tables_count=2 --num-threads=8 \ --mysql-user=root --mysql-host=127.0.0.1 --mysql-port=13002 prepare sysbench 0.5: multi-threaded system evaluation benchmark Creating table sbtest1... Inserting 10000 records into sbtest1 Creating secondary indexes on sbtest1... Creating table sbtest2... Inserting 10000 records into sbtest2 Creating secondary indexes on sbtest2... 9

Standard and Custom Tests: SysBench Comes with standard OLTP tests $ sysbench --test=/home/sveta/src/sysbench/sysbench/tests/db/oltp.lua \ --mysql-engine-trx=yes --mysql-table-engine=innodb --oltp_table_size=10000 \ --oltp_tables_count=2 --num-threads=8 \ --mysql-user=root --mysql-host=127.0.0.1 --mysql-port=13002 run sysbench 0.5: multi-threaded system evaluation benchmark Running the test with following options: Number of threads: 8 Random number generator seed is 0 and will be ignored Threads started!... 9 Threads fairness: events (avg/stddev): 1281.0000/12.29 execution time (avg/stddev): 1564.7510/1.16

Standard and Custom Tests: SysBench Comes with standard OLTP tests Standard tests help to Imitate some activity Generate binary log events Test effect of options/upgrades 9

Standard and Custom Tests: SysBench Comes with standard OLTP tests Standard tests help to Standard OLTP tests include Read only INSERTs only DELETEs only Mixed More 9

Standard and Custom Tests: SysBench Comes with standard OLTP tests Standard tests help to Standard OLTP tests include SysBench has standard hardware tests 9

Standard and Custom Tests: SysBench Comes with standard OLTP tests Standard tests help to Standard OLTP tests include SysBench has standard hardware tests I use mostly OLTP for troubleshooting 9

Custom SysBench Tests True power for troubleshooting You can imitate any load Supports Lua scripting 10

SysBench: Test Structure thread init Initialize thread 11

SysBench: Test Structure thread init set vars Set user variables 11

SysBench: Test Structure thread init set vars prepare Prepare test 11

SysBench: Test Structure thread init set vars prepare event Run event 11

SysBench: Test Structure thread init set vars prepare event cleanup Cleanup test 11

SysBench: Test Structure thread init set vars prepare event cleanup Version 1.0+ sysbench.cmdline.options sysbench.cmdline.commands 11

SysBench 0.5+: Variables function set_vars() branches_size = branches_size or 1 tellers_size = tellers_size or 10 accounts_size = accounts_size or 100000 scale = scale or 1 mysql_table_engine = mysql_table_engine or "innodb" end function thread_init(thread_id) set_vars() end 12

SysBench 1.0+: Variables sysbench.cmdline.options = { branches_size = {"Size of branches table", 1}, tellers_size = {"Size of tellers table", 10}, accounts_size = {"Size of accounts table", 100000}, scale = {"Test scale", 1}, mysql_table_engine = {"MySQL storage engine", "innodb"} } 13

SysBench 0.5+: Test Preparation 14 function prepare() set_vars() db_connect() db_query([[ create table accounts( aid int not null primary key, bid int, abalance int, filler char(84) ) /*! ENGINE = ]].. mysql_table_engine.. [[ default character set=latin1 */ ]]) db_bulk_insert_init("insert into branches (bid, bbalance, filler) values") for i=1,(branches_size * scale) do db_bulk_insert_next("(".. i.. ", 0, )") end db_bulk_insert_done() end

SysBench 0.5+: Test Run function event(thread_id) local aid = sb_rand(1, accounts_size * scale) end db_query("select abalance FROM accounts WHERE aid = ".. aid) 15

SysBench 0.5+: Hot Options num-threads max-requests max-time mysql-db mysql-host user port... Number of threads to use Maximum number of events Total execution time Schema to run tests in Connection options 16

SysBench 1.0+: Hot Options threads events time db-ps-mode mysql-db mysql-host user port... Number of threads to use Maximum number of events Total execution time Prepared statements mode Schema to run tests in Connection options 17

SysBench 1.0+: Major Scripting Improvements Scripts can declare options Default values SysBench can validate options Options are visible in help output 18

SysBench 1.0+: Major Scripting Improvements Scripts can declare options Parallel execution 18

SysBench 1.0+: Major Scripting Improvements Scripts can declare options Parallel execution Processing result sets 18

SysBench 1.0+: Major Scripting Improvements Scripts can declare options Parallel execution Processing result sets Custom commands 18

SysBench 1.0+: Major Scripting Improvements Scripts can declare options Parallel execution Processing result sets Custom commands Better reporting 18

SysBench 1.0+: Major Scripting Improvements Scripts can declare options Parallel execution Processing result sets Custom commands Better reporting sysbench 1.0: teaching an old dog new tricks 18

Case Study: Slave Crash

The Issue Multi-channel slave One master runs load on a table Another master runs FLUSH SLOW LOGS Is this FLUSH reason for the crash? 20

Setup Slave and two masters 21

Setup Slave and two masters Copy options from production 21

Setup Slave and two masters Copy options from production To imitate load on updating master $ mysqlslap --defaults-file=./.my_updating_master.cnf --concurrency=50 \ --number-of-queries=500000000 \ --pre-query="create TABLE IF NOT EXISTS test.t(ts varchar(26), \ id int unsigned not null primary key, f1 varchar(255), \ f2 bigint unsigned, f3 varchar(255), f4 bigint unsigned);" \ --query="replace INTO t (ts, id, f1, f2, f3, f4) VALUES \ (now(), 1000*rand(), md5(rand()), 1000000*rand(), fixed, 10000*rand())" \ --create-schema=test 21

Setup Slave and two masters Copy options from production To imitate load on updating master Load on flushing master $ while (true); do mysql -e "flush slow logs"; done 21

Setup Slave and two masters Copy options from production To imitate load on updating master Load on flushing master Standard Sysbench OLTP load on slave $ sysbench --threads=16 --events=0 --time=0 \ --mysql-host=127.0.0.1 --mysql-port=13002 --mysql-user=root \./oltp_read_only.lua --tables=4 --table_size=10000 prepare 21

Setup Slave and two masters Copy options from production To imitate load on updating master Load on flushing master Standard Sysbench OLTP load on slave $ sysbench --threads=16 --events=0 --time=0 \ --mysql-host=127.0.0.1 --mysql-port=13002 --mysql-user=root \./oltp_read_only.lua --tables=4 --table_size=10000 run 21

Setup Slave and two masters Copy options from production To imitate load on updating master Load on flushing master Standard Sysbench OLTP load on slave Slave did not crash I will create better test 21

Custom SysBench Script on Updating Master Options sysbench.cmdline.options = { table_size = {"Number of rows per table", 1000}, tables = {"Number of tables", 1} } 22

Custom SysBench Script on Updating Master Commands sysbench.cmdline.commands = { prepare = {cmd_prepare, sysbench.cmdline.parallel_command}, run = {cmd_run, sysbench.cmdline.parallel_command} } Must be after function definitions 22

Custom SysBench Script on Updating Master Thread initialization for run command function thread_init() drv = sysbench.sql.driver() con = drv:connect() end 22

Custom SysBench Script on Updating Master Values templates local ts_value_template = "####-##-#####:##:##.######" local f1_value_template = "######-###.######" local f3_value_template = "#####-###.######" 22

Custom SysBench Script on Updating Master Prepare command function cmd_prepare() local drv = sysbench.sql.driver() local con = drv:connect() for i = sysbench.tid % sysbench.opt.threads + 1, sysbench.opt.tables, sysbench.opt.threads do create_table(con, i) end end 22

Custom SysBench Script on Updating Master create table definition function create_table(con, table_num) local query print(string.format("creating table sbtest%d...", table_num)) query = string.format([[ CREATE TABLE sbtest%d( ts varchar(26), id int unsigned not null primary key, f1 varchar(255), f2 bigint unsigned, f3 varchar(255), f4 bigint unsigned ) engine=innodb]], table_num) 22 con:query(query)

Custom SysBench Script on Updating Master 22 create table definition if (sysbench.opt.table_size > 0) then print(string.format("inserting %d records into sbtest%d ", sysbench.opt.table_size, table_num)) end query = "INSERT INTO sbtest".. table_num.. "(ts, id, f1, f2, f3, f4) VALUES" con:bulk_insert_init(query) for i = 1, sysbench.opt.table_size do query = string.format("( %s, %d, %s, %d, %s, %d)", sysbench.rand.string(ts_value_template), i, sysbench.rand.string(f1_value_template), sb_rand(1, sysbench.opt.table_size), sysbench.rand.string(f3_value_template), sb_rand(1, sysbench.opt.table_size)) con:bulk_insert_next(query) end con:bulk_insert_done() end

Custom SysBench Script on Updating Master Load test itself function event() local table_name = "sbtest".. sysbench.rand.uniform(1, sysbench.opt.tables) local query = string.format("replace INTO %s (ts, id, f1, f2, f3, f4) VALUES ".. "( %s, %d, %s, %d, %s, %d)", table_name, sysbench.rand.string(ts_value_template), sb_rand(1, sysbench.opt.table_size), sysbench.rand.string(f1_value_template), sb_rand(1, sysbench.opt.table_size), sysbench.rand.string(f3_value_template), sb_rand(1, sysbench.opt.table_size)) end con:query(query) 22

Custom SysBench Script on Updating Master 22 Preparing... $ sysbench --threads=16 --events=0 --time=0 \ --mysql-host=127.0.0.1 --mysql-port=13001 --mysql-user=root \ slave_crash.lua --tables=4 --table_size=10000 prepare WARNING: Both event and time limits are disabled, running an endless test sysbench 1.0.14-aa52c53 (using bundled LuaJIT 2.1.0-beta2) Initializing worker threads... Creating table sbtest2... Creating table sbtest1... Creating table sbtest4... Creating table sbtest3... Inserting 10000 records into sbtest1 Inserting 10000 records into sbtest2 Inserting 10000 records into sbtest4 Inserting 10000 records into sbtest3

Custom SysBench Script on Updating Master And executing $ sysbench --threads=16 --events=0 --time=0 \ --mysql-host=127.0.0.1 --mysql-port=13001 --mysql-user=root \ slave_crash.lua --tables=4 --table_size=10000 run WARNING: Both event and time limits are disabled, running an endless test sysbench 1.0.14-aa52c53 (using bundled LuaJIT 2.1.0-beta2) Running the test with following options: Number of threads: 16 Initializing random number generator from current time Initializing worker threads... Threads started! 22

Custom SysBench Script on Updating Master Now wait 22

Why Do I Do Load Tests?

Customer s Performance Issues An option makes our server X % slower Feature is slow Query is slow Benchmarks techniques 24

Effect of Options Before recommending for customers To identify improvements in new versions To find out if common guess is working 25

To Repeat Locking issues Crashes Other concurrency issues 26

Generate Data Built-in data generation functionality Scriptable data distribution function set_vars() branches_size = branches_size or 1 tellers_size = tellers_size or 10 accounts_size = accounts_size or 100000 scale = scale or 1 mysql_table_engine = mysql_table_engine or "innodb" end 27

Generate Data Built-in data generation functionality Scriptable data distribution function prepare() set_vars() db_connect()... db_bulk_insert_init("insert into branches (bid, bbalance, filler) values") for i=1,(branches_size * scale) do db_bulk_insert_next("(".. i.. ", 0, )") end db_bulk_insert_done()... 27

Generate Data 27 Built-in data generation functionality Scriptable data distribution function prepare()... db_bulk_insert_init("insert into tellers (tid, bid, tbalance, filler) values") for i=1,(tellers_size * scale) do db_bulk_insert_next("(".. i.. ", ".. ((i % (branches_size * scale)) + 1).. ", 0, )") end db_bulk_insert_done() db_bulk_insert_init("insert into accounts (aid, bid, abalance, filler) values") for i=1,(accounts_size * scale) do db_bulk_insert_next("(".. i.. ", ".. ((i % (branches_size * scale)) + 1).. ", 0, )") end db_bulk_insert_done()...

Machines Which I Use

Exclusive Lab Machine Ideal solution Requirement for true benchmarks Performance tests Test which require use of all machine resources 29

Percona Shared Lab Machine Tests which needs to be shared High resource usage tests Long running tests Can affect and be affected by tests of others 30

My Own Laptop Short tests Not requiring powerful hardware Test drafts before porting them to lab machines 31

Binaries Which I Use

Standard Binaries Same as customers use With thoroughly tested options Optimized for performance 33

Self-Compiled Quick tests Special options Debug builds for crashes 34

How Do I Scale

Lack of disk space Copy only relevant data Only tables which participate in the problem Part of data if table is huge LIMIT WHERE mysqldump --where Only columns which participate in the query Not always leads to issue repetition! 36

Lack of CPU cores Some options must be scaled innodb thread concurrency innodb concurrency tickets 37 If you changed innodb thread concurrency, check the user manual innodb commit concurrency innodb purge threads innodb [read write] io threads thread concurrency thread cache size Only if you scale number or connections in your test

Lack of CPU cores Some options must be scaled Use scale coefficient SCALE = NUMBER OF CPU CORES ON PRODUCTION / NUMBER OF CPU CORES ON TEST 37

Lack of CPU cores 37 Some options must be scaled Use scale coefficient SCALE = NUMBER OF CPU CORES ON PRODUCTION / NUMBER OF CPU CORES ON TEST Example innodb thread concurrency test = innodb thread concurrency / SCALE Only if greater than number of CPU cores on the test server or unlimited

Scale coefficient example Table : innodb thread concurrency scale Production: 16 cores Test: 4 cores Adjust number of client threads? 0 0 It depends 4 4 Not 16 4 Yes 32 8 Yes 128 32 Yes 38

Disk-related options innodb io capacity Depends on disk speed! Can give very different results if disk speed is not taken in account innodb io capacity max 39

Lack of RAM Some options must be scaled 40

Lack of RAM Some options must be scaled Use scale coefficient SCALE = RAM ON PRODUCTION / RAM ON TEST 40

Lack of RAM Some options must be scaled Use scale coefficient SCALE = RAM ON PRODUCTION / RAM ON TEST Scale return time for performance tests 40

Lack of RAM 40 Some options must be scaled Use scale coefficient SCALE = RAM ON PRODUCTION / RAM ON TEST Scale return time for performance tests Use less data to repeat production slowdowns Care about data distribution! Check EXPLAIN output More waiting time can be better for testing: easier to notice difference

RAM-related options: scale them innodb buffer pool size innodb log file size only if changed buffer pool size innodb buffer pool chunk size only if very large on production It is unlikely what you will have to tune InnoDB Buffer Pool resizing 41

RAM-related options: scale them innodb buffer pool size innodb log file size innodb buffer pool chunk size innodb buffer pool instances Only if current number of instances does not make sense on test server. Example: 96G buffer pool on production with 12 instances and you test on laptop with 8G memory 41

RAM-related options: scale them innodb buffer pool size innodb log file size innodb buffer pool chunk size innodb buffer pool instances query cache size, key buffer size only if larger than available memory 41

RAM-related options: scale them innodb buffer pool size innodb log file size innodb buffer pool chunk size innodb buffer pool instances query cache size, key buffer size Do not adjust session options 41

RAM-related options: scale them 41 innodb buffer pool size innodb log file size innodb buffer pool chunk size innodb buffer pool instances query cache size, key buffer size Do not adjust session options table open cache, table definition cache

Session options: do not scale 42 join buffer size [max ]binlog [stmt ]cache size max heap table size tmp table size net buffer length parser max mem size read [rnd ]buffer size sort buffer size

Summary

Tools Described MySQL Command Line client Always 44

Tools Described MySQL Command Line client BASH Many queries in single thread 44

Tools Described MySQL Command Line client BASH mysqlslap Simple queries concurrently 44

Tools Described MySQL Command Line client BASH mysqlslap SysBench Custom tests 44

Summary Benchmarking tools More than just measuring performance Help when more than single query involved Imitate real life workload 45

Summary Benchmarking tools More than just measuring performance Help when more than single query involved Imitate real life workload Do much more than described in theirs user manuals if used creatively! 45

Call for Questions! Future webinar with MySQL benchmarking experts Send your questions https://twitter.com/svetsmirnova/status/999066023755223040 46

Thank you! http://www.slideshare.net/svetasmirnova https://twitter.com/svetsmirnova 47