Практическая оптимизация MySQL: измерять, чтобы ускорять / Петр Зайцев (Percona)

Post on 16-Apr-2017

1187 Views

Category:

Engineering

1 Downloads

Preview:

Click to see full reader

Transcript

Peter Zaitsev,CEO, Percona

November 3, 2015Highload++

Moscow, Russia

Practical MySQL Performance Optimization

www.percona.com2

Few Words About Percona

Your Partner in MySQL and

MongoDB Success

100% Open Source Software

“No Lock in Required” Solutions

and Services

We work with MySQL, MariaDB,

MongoDB, Amazon RDS and Aurora

2

www.percona.com3

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.com4

First Things First

MySQL Performance does

not Matter!

www.percona.com5

What DOES Matter?

Application Performance!

www.percona.com6

Even More so

Application Performance Always Matters!

www.percona.com7

Take Away

Performance Problems might not be MySQL Performance Solutions might not be with MySQL

www.percona.com8

Many “Tools”

• MongoDB• Cassandra• Hadoop• Elastic Search• Redis

Use the best Tool

for the job

www.percona.com9

Say Performance

Think aboutResponse Time

www.percona.com10

Related Issues

Stability

Scalability

Efficiency

www.percona.com11

Scalability?

•Load•Data Size•Infrastructure

Scalability with:

www.percona.com12

Performance “Sandbags”

Security

Manageability

Compatibility

Compliance

Ease of use by Developers

www.percona.com13

“Good Enough”

You can always

improve your system. Know when to stop.

www.percona.com14

What MySQL Does

•Selects• Inserts•Deletes•Updates

Processes Queries

www.percona.com15

What to focus on?

•Making queries run faster

•Using less resources

•Scaling better

Performance

Optimization focused

www.percona.com16

Transaction Optimization

•Find out which queries it runs

•Optimize them

Specific Application Transactio

n

www.percona.com17

General Optimization

•Prioritize them

•Optimize them

Look at

what querie

s Server Runs

www.percona.com18

Queries

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

Are those the

right queries

?

www.percona.com19

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.com20

Query Tips

Do less queries – latency and overhead

Read or 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.com21

Schema

•Minor Schema changes

•Data Architecture

Look at Schema and Querie

s togethe

r

www.percona.com22

Schema Tips

• http://bit.ly/1rAtamELearn 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.com23

The Following Also Matter

Infrastructure

Operating System and Configuration

MySQL Version

MySQL Configuration

www.percona.com24

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.com25

Infrastructure

Scaling Up or Out

• One MySQL Node

• Many MySQL Nodes

Type

• Public Cloud • Private Cloud • Bare Metal

www.percona.com26

Hardware

CPU

Memory

Disk

Network

www.percona.com27

CPU

Intel owns the market

2 sockets commonly used

Faster cores or more cores

Turboboost

www.percona.com28

Memory

Main purpose – Cache

Think Database size vs Memory

Look together with Storage Optimization

www.percona.com29

Invest in Memory or Storage

www.percona.com30

Storage

Types

• Directly Attached

• SAN • NAS• Virtualized

Flash

• PCI-E• SATA

“Disks”• TLC, MLC,

eMLC, SLC

RAID

• Hardware• Software• Filesystem

www.percona.com31

Network

Latency

• Distance• Number of

“Hops”

Throughput

• 1Gb is a must, trunking recommended

• 10Gb increasingly affordable

Availability

• Bonding• Multipath

www.percona.com32

OS Choices

Linux

Server grade

Recent

Supporting MySQL well

www.percona.com33

OS Tuning

Defaults are good for common workloads

Filesystem: EXT4 or XFS

More Detail http://bit.ly/MySQLonLinux

www.percona.com34

MySQL Version

New versions typically improve performance

MySQL 5.7 is available now!

Scalability, Improved Optimizer, etc.

Expect some regressions

Try Percona Server 5.6

www.percona.com35

MySQL Configuration

Do not run with defaults

Do not ever obsess with tuning

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

www.percona.com36

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.com37 www.percona.com

Tools and The Process

www.percona.com38

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.com39

Queries will be impacted

Hardware Changes

Configuration

MySQL Version Changes

Impact of Data Growth

Changes to the Query Mix

Optimizer Plan Changes

www.percona.com40

Tools

PT-Query-Digest from Percona Toolkit

MySQL Enterprise Monitor

MonYog

VividCortex

Graphite

www.percona.com41

Performance Schema + Graphite

• Performance Schema allows to plot query information as time series

• Solution for Graphite• Working on easy to use one for Grafana• http://bit.ly/1KQSNWC

www.percona.com42

Graphite Example

www.percona.com43

Query Profile

www.percona.com44

Server Profile

www.percona.com45

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.com46

Want More ?

I’m talking about MySQL Replication Options

Free (as in Beer) Moscow MySQL Users Group meetup November 6th,

Hosted by Mail.ru

http://www.meetup.com/moscowmysql/

46

www.percona.com47

Percona Live 2016 call for paper is Open

Call for Papers Open until November 29, 2016

MySQL, MongoDB, NoSQL, Data in The Cloud

Anything to make Data Happy!

http://bit.ly/PL16Call

47

www.percona.com48 www.percona.com

Peter Zaitsevpz@percona.com

P.S We’re Hiring http://bit.ly/PerconaJobs

Thank You!

top related