Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right...

Post on 08-Jun-2020

3 views 0 download

Transcript of Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right...

Peter Zaitsev, CEO, Percona July 20th, 2016

Percona Technical Webinars

Practical MySQL Performance Optimization

www.percona.com 2

In This Presentation We’ll

Look at how to approach Performance Optimization

Discuss Practical Performance Optimization Tips

Look at the Tools which can help us

www.percona.com 3

First Things First

MySQL Performance does not Matter!

www.percona.com 4

What DOES Matter?

Application Performance!

www.percona.com 5

Even More so

Application Performance Always Matters!

www.percona.com 6

Take Away

Performance Problems might not be MySQL

Performance Solutions might not

be with MySQL

www.percona.com 7

Many “Tools”

• MongoDB • Cassandra • Hadoop • Spark • Elastic • Redis

Use the best

Tool for the job

www.percona.com 8

Say Performance

Think about Response Time

www.percona.com 9

Related Issues

Stability

Scalability

Efficiency

www.percona.com 10

Scalability?

• Load • Data Size • Infrastructure

Scalability with:

www.percona.com 11

Performance “Sandbags”

Security

Manageability

Compatibility

Compliance

Ease of use by Developers

www.percona.com 12

“Good Enough”

You can always

improve your system. Know when to stop.

www.percona.com 13

What MySQL Does

• Selects • Inserts • Deletes • Updates

Processes Queries

www.percona.com 14

What to focus on?

• Making queries run faster

• Using less resources

• Scaling better

Performance Optimization

focused

www.percona.com 15

Transaction Optimization

• Find out which queries it runs

• Optimize them

Specific Application Transaction

www.percona.com 16

General Optimization

• Prioritize them • Optimize them

Look at what

queries Server Runs

www.percona.com 17

Queries

• Get rid of them? • Can we change them to be doing less work?

Are those the

right queries ?

www.percona.com 18

Things to Consider

• But avoid focusing only on outliers

Do not look at the average case only

• Consider daily, weekly, monthly cycles

Look at trends over time

• Data size change? Cardinality?

Think about future

performance

www.percona.com 19

Query Tips

Do less queries – latency and overhead

Read less data; Modify less data

Less data processing on the fly

How much data is traversed vs sent

How much data is sent vs used by app

www.percona.com 20

Schema

• Minor Schema changes

• Data Architecture

Look at Schema

and Queries together

www.percona.com 21

Schema Tips

•  http://bit.ly/1rAtamE Learn Indexing

•  Starting with Text book schema is OK ending is likely not

Design Schema for data access

•  Partitioning & Sharding •  Normalization and Denormalization •  Covering Indexes

Technics

www.percona.com 22

The Following Also Matter

Infrastructure

Operating System and Configuration

MySQL Version

MySQL Configuration

www.percona.com 23

Optimization Process

Low Hanging Fruit

•  MySQL Configuration

•  OS Settings •  Indexes •  Caching

Medium Level

•  Infrastructure •  OS •  MySQL

Version

Hard Changes

•  Major schema changes

•  Application architecture change

www.percona.com 24

Infrastructure

Scaling Up or Out

• One MySQL Node

• Many MySQL Nodes

Type

• Public Cloud • Private Cloud • Bare Metal

www.percona.com 25

Hardware

CPU

Memory

Disk

Network

www.percona.com 26

CPU

Intel owns the market

2 sockets commonly used

Faster cores or more cores

Turboboost

www.percona.com 27

Memory

Main purpose – Cache

Think Database size vs Memory

Look together with Storage Optimization

www.percona.com 28

Invest in Memory or Storage

www.percona.com 29

Storage

Types

•  Directly Attached

•  SAN •  NAS •  Virtualized •  Cloud

Flash

•  PCI-E •  SATA

“Disks” •  TLC, MLC,

eMLC, SLC

RAID

•  Hardware •  Software •  Filesystem

www.percona.com 30

Network

Latency

•  Distance •  Number of

“Hops”

Throughput

•  1Gb is a must, trunking recommended

•  10Gb increasingly affordable

Availability

•  Bonding •  Multipath

www.percona.com 31

OS Choices

Linux

Server grade

Recent

Supporting MySQL well

www.percona.com 32

OS Tuning

Defaults are good for common workloads

Filesystem: EXT4 or XFS

More Detail http://bit.ly/MySQLonLinux

www.percona.com 33

MySQL Version

New versions typically improve performance

MySQL 5.7 – Current GA

Scalability, Improved Optimizer, etc.

Expect some regressions

Try Percona Server 5.7

www.percona.com 34

MySQL Configuration

Do not run with defaults

Do not ever obsess with tuning

More Details: http://bit.ly/1vth5Cu

www.percona.com 35

MySQL Tuning in 1 slide

•  max_connections •  log_bin •  table_open_cache_size •  table_definitions_cache_size •  open_files_limit •  innodb_buffer_pool_size •  innodb_log_file_size •  Innodb_flush_log_at_trx_commit •  Innodb_flush_method=O_DIRECT

www.percona.com 36 www.percona.com

Tools and The Process

www.percona.com 37

Process

• Do not bring bad queries and schema in production

Developers Part

• Catch bad queries • Validate changes in hardware,

configuration, versions

Operations Process

www.percona.com 38

Queries will be impacted

Hardware Changes

Configuration

MySQL Version Changes

Impact of Data Growth

Changes to the Query Mix

Optimizer Plan Changes

www.percona.com 39

Tools

PT-Query-Digest from Percona Toolkit

MySQL Enterprise Monitor

MonYog

VividCortex

PMM (Percona Monitoring and Management)

www.percona.com 40

More on PMM

Percona’s Open Source solution for MySQL and MongoDB Monitoring

Currently In Beta

Planning to add Management in the Future

Check it out yourself at http://pmmdemo.percona.com

www.percona.com 41

Quick PMM Demo

www.percona.com 42

To Sum it Up

It is Application Performance what Matters!

Use Right Tools for Right Job

See what Queries MySQL is Running

Reduce Number of Queries

Reduce Data They Return

See how they can do less work

Do that work more efficiently

www.percona.com 43

Join us at Percona Live Europe! When: October 3-5, 2016 Where: Amsterdam, Netherlands The Percona Live Open Source Database Performance Conference is a great event for users of any level using open source database technologies.

•  Get briefed on the hottest topics •  Learn about building and maintaining high-performing deployments •  Listen to technical experts and top industry leaders Get the early bird rate before prices go up on July 26th! Register now Sponsorship opportunities available as well here.

www.percona.com 44 www.percona.com

Peter Zaitsev https://www.linkedin.com/in/peterzaitsev

P.S We’re Hiring

http://bit.ly/PerconaJobs

Thank You!