Another MySQL Performance Talk
Transcript of Another MySQL Performance Talk
-
8/14/2019 Another MySQL Performance Talk
1/35
Another MySQL PerformanceMorgan Tocker
mailto:[email protected]:[email protected] -
8/14/2019 Another MySQL Performance Talk
2/35
Topics Ill cover
How *not* to benchmark
Disk CPU RAM or Network? MySQL Topologies
-
8/14/2019 Another MySQL Performance Talk
3/35
How *not* to benchmark
-
8/14/2019 Another MySQL Performance Talk
4/35
My favorite quote...
I tested both MyISAM and InnoDB and accessing the sam1000 times it was always faster in MyISAM....
-
8/14/2019 Another MySQL Performance Talk
5/35
Why?
-
8/14/2019 Another MySQL Performance Talk
6/35
Why?
By using the same URL you almost guaranteed that it win:
-
8/14/2019 Another MySQL Performance Talk
7/35
Why?
By using the same URL you almost guaranteed that it win:
The query_cache (if enabled)
-
8/14/2019 Another MySQL Performance Talk
8/35
Why?
By using the same URL you almost guaranteed that it win:
The query_cache (if enabled)
The MySQL key_cache (if MyISAM) for the index blocks
-
8/14/2019 Another MySQL Performance Talk
9/35
Why?
By using the same URL you almost guaranteed that it win:
The query_cache (if enabled)
The MySQL key_cache (if MyISAM) for the index blocks
The InnoDB buffer pool (both indexes and data) and the Iadaptive hash
-
8/14/2019 Another MySQL Performance Talk
10/35
Why?
By using the same URL you almost guaranteed that it win:
The query_cache (if enabled)
The MySQL key_cache (if MyISAM) for the index blocks
The InnoDB buffer pool (both indexes and data) and the Iadaptive hash
A filesystem cache. Maybe even a disk cache, or the drive might be at the right location to minimize seek.
-
8/14/2019 Another MySQL Performance Talk
11/35
What else is wrong?
Youve also omitted other key problems from your test.
Cant catch potential deadlocks, Table locking
Any issues where disk Starvation etc occurs.
-
8/14/2019 Another MySQL Performance Talk
12/35
My second favorite quote.
My systems average load is 0.10 with 100 connections, so able to support somewhere up to 1000 connections.
Rarely true.
Bottlenecks shift.
Multi-cores and multi CPUs are exposing new problems.BUG #15815, BUG #30738, BUG #26442
-
8/14/2019 Another MySQL Performance Talk
13/35
Tools to use
Apache benchmark (ab)
http_load
Similar to ab, can accept an input file of URLs (apache accemakes a good victim)
Custom shell scripts
curl $url
-
8/14/2019 Another MySQL Performance Talk
14/35
Disk RAM CPU or Networ
-
8/14/2019 Another MySQL Performance Talk
15/35
Potential Bottlenecks
DISK RAM
CPU Network
-
8/14/2019 Another MySQL Performance Talk
16/35
Potential Bottlenecks
DISKThe number one bottleneck.
Seriously.RAM
CPU Network
-
8/14/2019 Another MySQL Performance Talk
17/35
Potential Bottlenecks
DISKThe number one bottleneck.
Seriously.
RAMUse it to cheat - get o
your DISK whereve
CPU Network
-
8/14/2019 Another MySQL Performance Talk
18/35
Potential Bottlenecks
DISKThe number one bottleneck.
Seriously.
RAMUse it to cheat - get o
your DISK whereve
CPUMay report as high if
heavy wait I/O.Network
-
8/14/2019 Another MySQL Performance Talk
19/35
Potential Bottlenecks
DISKThe number one bottleneck.
Seriously.
RAMUse it to cheat - get o
your DISK whereve
CPUMay report as high if
heavy wait I/O.
NetworkMaximum throughp
normally an issue, butadd latency
-
8/14/2019 Another MySQL Performance Talk
20/35
My Advice:
Better value in fixing the bigger problems first.
Sometimes this means not buying expensive CPUs and GigaEthernet cards.
-
8/14/2019 Another MySQL Performance Talk
21/35
Warning! Your bottleneckmay change
Whats percentage of your data fits nicely into RAM?
Almost any sloppy design will work with a dataset of 1G
Can you afford the same when your dataset is 90G?
-
8/14/2019 Another MySQL Performance Talk
22/35
My favorite unixy command
iostat -d 60 5 > /tmp/iostat.txt &
df -h
vmstat 60 5 > /tmp/vmstat.txt &
free
lsof
-
8/14/2019 Another MySQL Performance Talk
23/35
My favorite unixy command(cont.)
ps aux
uptime
top
netstat
ping -f
-
8/14/2019 Another MySQL Performance Talk
24/35
My advice: Hard Drives
RAID 10 is the best (slightly better write speed than RAID5
Be careful that cheaper cards apparently do RAID5 in some reduced performance way
Drive speed also counts (10K, 15K RPM)
-
8/14/2019 Another MySQL Performance Talk
25/35
My advice: Hard Drives (con
Slower drives cant fsync() fast enough, so youll still be writ
Battery backed write caches on RAID controllers kick ars
You can distribute InnoDB log files or binary log files for beIO distribution
-
8/14/2019 Another MySQL Performance Talk
26/35
Some things to try...
mount drives with noatime
experiment with different IO schedulers
Temporary tables that need to be created on disk in MySQLredirected to a tmpfs
Youll want to reduce the size of max_heap_table_size andtmp_table_size
-
8/14/2019 Another MySQL Performance Talk
27/35
Topologies that scale
-
8/14/2019 Another MySQL Performance Talk
28/35
In the beginning...
www
+ mysql
Internet
-
8/14/2019 Another MySQL Performance Talk
29/35
The next logical step...
www
Internet
mysql
-
8/14/2019 Another MySQL Performance Talk
30/35
The next logical step (cont
www
Internet
mysql
-
8/14/2019 Another MySQL Performance Talk
31/35
Continued Growth...
www
Internet
master
reads
x N
slaves
writes
-
8/14/2019 Another MySQL Performance Talk
32/35
-
8/14/2019 Another MySQL Performance Talk
33/35
Where this hits the wall..
Writes
Reads
Writes
Reads
Writes
Reads
Writes
Reads
Writes
Unused
Writes
Reads
Write
Read
* Single replication thread makes this even worse than it loo
-
8/14/2019 Another MySQL Performance Talk
34/35
You need to (partition) shar
Use groups of Master, Slave, Slave for different tasks:
Do logging tables ever join on the other tables?
Maybe have a global user table and store user_details on dgroups of servers.
Different servers for searching
-
8/14/2019 Another MySQL Performance Talk
35/35
The End(Heres where I givetime for other Q&A)