practical mysql performance optimization...it is application performance what matters! use right...
TRANSCRIPT
![Page 1: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/1.jpg)
Peter Zaitsev, CEO, Percona July 20th, 2016
Percona Technical Webinars
Practical MySQL Performance Optimization
![Page 2: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/2.jpg)
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
![Page 3: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/3.jpg)
www.percona.com 3
First Things First
MySQL Performance does not Matter!
![Page 4: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/4.jpg)
www.percona.com 4
What DOES Matter?
Application Performance!
![Page 5: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/5.jpg)
www.percona.com 5
Even More so
Application Performance Always Matters!
![Page 6: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/6.jpg)
www.percona.com 6
Take Away
Performance Problems might not be MySQL
Performance Solutions might not
be with MySQL
![Page 7: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/7.jpg)
www.percona.com 7
Many “Tools”
• MongoDB • Cassandra • Hadoop • Spark • Elastic • Redis
Use the best
Tool for the job
![Page 8: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/8.jpg)
www.percona.com 8
Say Performance
Think about Response Time
![Page 9: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/9.jpg)
www.percona.com 9
Related Issues
Stability
Scalability
Efficiency
![Page 10: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/10.jpg)
www.percona.com 10
Scalability?
• Load • Data Size • Infrastructure
Scalability with:
![Page 11: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/11.jpg)
www.percona.com 11
Performance “Sandbags”
Security
Manageability
Compatibility
Compliance
Ease of use by Developers
![Page 12: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/12.jpg)
www.percona.com 12
“Good Enough”
You can always
improve your system. Know when to stop.
![Page 13: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/13.jpg)
www.percona.com 13
What MySQL Does
• Selects • Inserts • Deletes • Updates
Processes Queries
![Page 14: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/14.jpg)
www.percona.com 14
What to focus on?
• Making queries run faster
• Using less resources
• Scaling better
Performance Optimization
focused
![Page 15: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/15.jpg)
www.percona.com 15
Transaction Optimization
• Find out which queries it runs
• Optimize them
Specific Application Transaction
![Page 16: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/16.jpg)
www.percona.com 16
General Optimization
• Prioritize them • Optimize them
Look at what
queries Server Runs
![Page 17: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/17.jpg)
www.percona.com 17
Queries
• Get rid of them? • Can we change them to be doing less work?
Are those the
right queries ?
![Page 18: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/18.jpg)
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
![Page 19: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/19.jpg)
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
![Page 20: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/20.jpg)
www.percona.com 20
Schema
• Minor Schema changes
• Data Architecture
Look at Schema
and Queries together
![Page 21: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/21.jpg)
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
![Page 22: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/22.jpg)
www.percona.com 22
The Following Also Matter
Infrastructure
Operating System and Configuration
MySQL Version
MySQL Configuration
![Page 23: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/23.jpg)
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
![Page 24: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/24.jpg)
www.percona.com 24
Infrastructure
Scaling Up or Out
• One MySQL Node
• Many MySQL Nodes
Type
• Public Cloud • Private Cloud • Bare Metal
![Page 25: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/25.jpg)
www.percona.com 25
Hardware
CPU
Memory
Disk
Network
![Page 26: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/26.jpg)
www.percona.com 26
CPU
Intel owns the market
2 sockets commonly used
Faster cores or more cores
Turboboost
![Page 27: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/27.jpg)
www.percona.com 27
Memory
Main purpose – Cache
Think Database size vs Memory
Look together with Storage Optimization
![Page 28: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/28.jpg)
www.percona.com 28
Invest in Memory or Storage
![Page 29: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/29.jpg)
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
![Page 30: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/30.jpg)
www.percona.com 30
Network
Latency
• Distance • Number of
“Hops”
Throughput
• 1Gb is a must, trunking recommended
• 10Gb increasingly affordable
Availability
• Bonding • Multipath
![Page 31: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/31.jpg)
www.percona.com 31
OS Choices
Linux
Server grade
Recent
Supporting MySQL well
![Page 32: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/32.jpg)
www.percona.com 32
OS Tuning
Defaults are good for common workloads
Filesystem: EXT4 or XFS
More Detail http://bit.ly/MySQLonLinux
![Page 33: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/33.jpg)
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
![Page 34: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/34.jpg)
www.percona.com 34
MySQL Configuration
Do not run with defaults
Do not ever obsess with tuning
More Details: http://bit.ly/1vth5Cu
![Page 35: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/35.jpg)
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
![Page 36: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/36.jpg)
www.percona.com 36 www.percona.com
Tools and The Process
![Page 37: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/37.jpg)
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
![Page 38: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/38.jpg)
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
![Page 39: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/39.jpg)
www.percona.com 39
Tools
PT-Query-Digest from Percona Toolkit
MySQL Enterprise Monitor
MonYog
VividCortex
PMM (Percona Monitoring and Management)
![Page 40: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/40.jpg)
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
![Page 41: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/41.jpg)
www.percona.com 41
Quick PMM Demo
![Page 42: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/42.jpg)
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
![Page 43: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/43.jpg)
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.
![Page 44: Practical MySQL Performance Optimization...It is Application Performance what Matters! Use Right Tools for Right Job See what Queries MySQL is Running Reduce Number of Queries Reduce](https://reader030.vdocument.in/reader030/viewer/2022041104/5f03df907e708231d40b301e/html5/thumbnails/44.jpg)
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!