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

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

Innodb Performance Optimization

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

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

Practical MySQL Performance Optimization. Peter Zaitsev, CEO, Percona July 20 th, 2016 Percona Technical Webinars

Best Practices for MySQL Scalability. Peter Zaitsev, CEO, Percona Percona Technical Webinars May 1, 2013

Performance improvements in MySQL 5.5

Practical MySQL Performance Optimization. Peter Zaitsev, CEO, Percona July 02, 2015 Percona Technical Webinars

MySQL Database Scalability

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

Monitoring MySQL Performance with Percona Monitoring and Management

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

Open Source Database Performance Optimization and Monitoring with PMM. Fernando Laudares, Vinicius Grippa, Michael Coburn Percona

Why we re excited about MySQL 8

Innodb Architecture and Performance Optimization. Peter Zaitsev, CEO Percona 25 September 2017

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

Aurora, RDS, or On-Prem, Which is right for you

MySQL High Availability

ScaleArc Performance Benchmarking with sysbench

To Shard or Not to Shard That is the question! Peter Zaitsev April 21, 2016

Accelerating OLTP performance with NVMe SSDs Veronica Lagrange Changho Choi Vijay Balakrishnan

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

Using Percona Monitoring and Management to Troubleshoot MySQL Performance Issues

InnoDB: Status, Architecture, and Latest Enhancements

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

Innodb Architecture and Performance Optimization

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 8.0 Performance: InnoDB Re-Design

MySQL Performance Tuning

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

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

What s New in MySQL and MongoDB Ecosystem Year 2017

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

Replication features of 2011

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

BzTree: A High-Performance Latch-free Range Index for Non-Volatile Memory

Compression in Open Source Databases. Peter Zaitsev April 20, 2016

MySQL Performance Troubleshooting

Choosing Hardware and Operating Systems for MySQL. Apr 15, 2009 O'Reilly MySQL Conference and Expo Santa Clara,CA by Peter Zaitsev, Percona Inc

Architecture and Design of MySQL Powered Applications. Peter Zaitsev CEO, Percona Highload Moscow, Russia 31 Oct 2014

Troubleshooting Best Practices

Optimizing MySQL Configuration

SSD/Flash for Modern Databases. Peter Zaitsev, CEO, Percona November 1, 2014 Highload Moscow,Russia

The Right Read Optimization is Actually Write Optimization. Leif Walsh

Switching to Innodb from MyISAM. Matt Yonkovit Percona

SSD/Flash for Modern Databases. Peter Zaitsev, CEO, Percona October 08, 2014 Percona Technical Webinars

Monitoring MySQL Performance with Percona Monitoring and Management

MySQL In the Cloud. Migration, Best Practices, High Availability, Scaling. Peter Zaitsev CEO Los Angeles MySQL Meetup June 12 th, 2017.

Accelerate MySQL for Demanding OLAP and OLTP Use Case with Apache Ignite December 7, 2016

Performance of popular open source databases for HEP related computing problems

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

Bottleneck Hunters: How Schooner increased MySQL throughput by more than 800% Jeremy Cole

High availability with MariaDB TX: The definitive guide

Choosing Storage for MySQL. Peter Zaitsev CEO, Percona Inc Percona Live, Washington,DC 11 January 2012

MySQL: Scaling & High Availability

VMWARE VREALIZE OPERATIONS MANAGEMENT PACK FOR. Amazon Aurora. User Guide

PRESENTATION TITLE GOES HERE

ZFS and MySQL on Linux, the Sweet Spots

Scaling Without Sharding. Baron Schwartz Percona Inc Surge 2010

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

Optimizing MySQL Configuration. Peter Zaitsev,CEO Technical Webinars Series March 2012

MongoDB Monitoring and Performance for The Savvy DBA

Falcon: Scaling IO Performance in Multi-SSD Volumes. The George Washington University

PostgreSQL Performance The basics

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

Innodb Architecture and Internals. Peter Zaitsev Percona Live, Washington DC 11 January 2012

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

Analyzing and Optimizing Linux Kernel for PostgreSQL. Sangwook Kim PGConf.Asia 2017

Analysis of Derby Performance

InnoDB: What s new in 8.0

There And Back Again

Recovering Disk Storage Metrics from low level Trace events

Upgrading MySQL Best Practices. Apr 11-14, 2011 MySQL Conference and Expo Santa Clara,CA by Peter Zaitsev, Percona Inc

MySQL Performance Improvements

Percona Server for MySQL 8.0 Walkthrough

IT Best Practices Audit TCS offers a wide range of IT Best Practices Audit content covering 15 subjects and over 2200 topics, including:

MySQL Replication Options. Peter Zaitsev, CEO, Percona Moscow MySQL User Meetup Moscow,Russia

Compression in Open Source Databases. Peter Zaitsev CEO, Percona Percona Technical Webinars January 27 th, 2016

Forget IOPS: A Proper Way to Characterize & Test Storage Performance Peter Murray SwiftTest

On BigFix Performance: Disk is King. How to get your infrastructure right the first time! Case Study: IBM Cloud Development - WW IT Services

Tuesday, April 6, Inside SQL Server

Virtual Memory #2 Feb. 21, 2018

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

Accelerate MySQL for Demanding OLAP and OLTP Use Cases with Apache Ignite. Peter Zaitsev, Denis Magda Santa Clara, California April 25th, 2017

Here, we consider Database bottleneck as a problem and provide solution for some of common problems.

Optimizing MySQL performance with ZFS. Neelakanth Nadgir Allan Packer Sun Microsystems

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

What is MariaDB 5.5? w: e: Daniel Bartholomew Oct 2012

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

MyRocks in MariaDB. Sergei Petrunia MariaDB Tampere Meetup June 2018

Amazon Aurora Deep Dive

Choosing a MySQL High Availability Solution. Marcos Albe, Percona Inc. Live Webinar June 2017

MySQL Performance Tuning 101

OKC MySQL Users Group

A Performance Puzzle: B-Tree Insertions are Slow on SSDs or What Is a Performance Model for SSDs?

SQL Server Performance on AWS. October 2018

InnoDB: What s new in 8.0

Monitoring MySQL with Prometheus & Grafana

Microsoft SQL Server Database Administration

Accelerate Applications Using EqualLogic Arrays with directcache

Transcription:

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

Few words about Percona Monitoring and Management (PMM) 100% Free, Open Source database troubleshooting and performance optimization platform for MySQL and MongoDB Based on Industry Leading Technology Roll your own in and out of the Cloud 2

Exploring Percona Monitoring and Management You should be able to install PMM in 15 minutes or less Would like to follow along in the demo? http://bit.ly/installpmm https://pmmdemo.percona.com 3

In the Presentation Practical approach to deal with some of the common MySQL Issues 4

PMM is not just for MySQL Supports MongoDB as well Other databases can be added via External Exporters This Presentation is MySQL Focused 5

Assumptions You re looking to Have your MySQL Queries Run Faster You want to troubleshoot sudden MySQL Performance Problem You want to find way to run more efficiently (use less Resources) 6

How to Look at MySQL Performance Query Based Approach All the users (developers) care is how quickly their queries perform Resource Based Approach Queries use resources. Slow Performance often caused by resource constraints 7

Primary Resources CPU Disk IO Memory Network 8

Low Resource Usage + Poor Performance Contention Table Locks/Row Level Locks Locking/Latching in MySQL and Kernel Mixed Resource Usage Single worker spending 33% on CPU 33% Waiting on Disk 33% on Network Will not be seen as directly constrained by any resource 9

Load Average What can you tell me about server load? 10

Problems with Load Average Mixes CPU and IO resource usage (on Linux) Is not normalized for number of CPU cores available Does not keep into account Queue Depth Needed for optimal storage performance 11

CPU Usage Can observe overall or per core Matching Load Average in the previous screen 12

Saturation Metrics Good to understand where waits are happening IO Load is not normalized 13

Looking at CPU Saturation Separately Can normalize CPU Saturation based on number of threads 14

Row Locks Logical Contention Row Locks are often declared by transaction semantics But more transactions underway also mean more locks 15

Zooming in on Row Locks Wait Load How many MySQL Connections are Blocked because or Row Level Lock Waits 16

Load at MySQL Side threads_running - MySQL is busy handling query CPU? Disk? Row Level Locks? Need to dig deeper 17

MySQL Questions Inflow of Queries Are we serving more queries or less queries? Any spikes or dips? 18

Innodb Rows Actual Work Being Done Better number to think re system capacity Not all rows are created equal, but more equal than queries 19

Commands What kind of operations Note if prepared statements are used MySQL is double counting 20

MySQL Handlers low lever row access Works for all storage engines Gives more details on access type Mixes Temporary Tables and Non-Temporary tables together 21

Memory usage by MySQL Leave some memory available for OS Cache and other needs 22

Innodb in Depth

Innodb Checkpointing The log file size is good enough as Uncheckpointed bytes are fraction of log file size 24

Innodb Checkpointing Very Close Innodb Log File Size too small for optimal performance 25

Innodb Transaction History - not yet Purged Transactions Short term spikes are normal if some longer transactions are ran on the system 26

Innodb Transaction History Growth over long period of time without long queries in the processlist Often identifies orphaned transactions (left open) 27

Transaction History Recovery If Backlog is resolved quickly it is great If not you may be close to the limit of purge subsystem 28

Is your Innodb Log Buffer Large Enough? You will be surprised to see how little log buffer space Innodb needs 29

Another way to look at Logging Performance 30

Innodb IO Will often roughly match disk IO Allows to see the writes vs fsyncs 31

Hot Tables It is often helpful to know what tables are getting most Reads And Writes 32

Hot Tables through Performance Schema Even more details available in Performance Schema Load is a better measure of actual cost than number of events 33

Most Active Indexes See through which index queries access tables 34

What about Queries causing the most load? Can examine through Query Analytics application 35

Latency Details Explored Not enough to look at Average Latency 36

What are Top Queries? Queries Sorted by their Load Query ran 10 times over second each time taking 0.2 sec will be load 2 Not making a difference between queries causing the load or just impacted by it 37

Whole Server Summary #1 Server Summary Gives a good idea what is going on query wise 38

Whole Server Summary #2 39

Specific Query Update Query Significant part of response time comes from row level lock waits 40

Expensive SELECT Query Examining lots of rows per each row sent 41

Check Query Example Expensive Query not poorly optimized one 42

Explain and JSON Explain 43

Explore Any Captured Metrics Standard Dashboards are only tip of the iceberg You can also use Prometheus directly 44

Lets Look at Couple of Case Studies

Impact Of Durability? Running sysbench with rate=1000 to inject 1000 transactions every second System can handle workloads with both settings System previously running with sync_binlog=0 and innodb_flush_log_at_trx_commit=0 Set them to sync_binlog=1 and innodb_flush_log_at_trx_commit=1 46

IO Bandwith IO Bandwidth is not significantly impacted 47

IO Saturation Jumps a Lot 48

Read and Write Latencies are Impacted This SSD (Samsung 960 Pro) Does not like fsync() calls 49

More Disk IO Operations Frequent Fsync() causes more writes of smaller size to storage 50

Increase In Disk IO Load IO Avg Latency Increase + More IOPs = Load Increase 51

Disk IO Utilization jumps to 100% There is at least one disk IO Operation in flight all the time 52

Average IO Size is down Large block writes to binlog and innodb transaction logs do not happen any more 53

Number of Running Threads Impacted Need higher concurrency to be able to drive same number of queries/sec 54

MySQL Questions Why does it increase with same inflow of transactions? 55

Because of Deadlocks Some transactions have to be retried due to deadlocks Your well designed system should behave the same 56

Higher Row Lock Time Rows Locks can be only released after successful transaction commit Which now takes longer time due to number of fsync() calls 57

And Load Caused by Row Locks 58

Log Buffer Used even less with durability on 59

Is Group Commit Working? Do we relay on Group Commit for our workload 60

Top Queries Impacted Commit is now the highest load contributor 61

Changing Buffer Pool Size

MySQL 5.7 Allows to change BP Online Changing buffer pool from 48GB to 4GB online mysql> set global innodb_buffer_pool_size=4096*1024*1024; Query OK, 0 rows affected (0.00 sec) 63

QPS Impact While resizing is ongoing capacity is limited Queueing happens After resize completed backlog has to be worked off having higher number of queries 64

Saturation spike and when stabilizing on higher level Guess why the spike with lower QPS Level? 65

Two IO Spikes First to Flush Dirty Pages Second to work off higher query rate 66

What is about Disk IO Latency? Higher Number of IOPS does not always mean much higher latency 67

Longer Transactions = More Deadlocks 68

More IO Load Less Contention? Unsure why this is the case Note not ALL contention is shown in those graphs 69

Now we see query 80% IO Bound 70

Summary Can get a lot of Insights in MySQL Performance with PMM Great tool to have when you re challenged troubleshoot MySQL A lot of insights during benchmarking and evaluation 71

72

Percona to Support PostgreSQL 73

Thank You!