Upload
others
View
3
Download
0
Embed Size (px)
Citation preview
Peter Zaitsev, CEO, Percona July 02, 2015
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 • Elastic Search • Redis
Use the best
Tool for the job
www.percona.com 8
Say Performance
Think 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
Economics Performance Optimization
Positive Business Impact
Negative Business Impact
www.percona.com 14
Positive (How to get a Budget)
• Downtime Very Slow Performance
• More Engaged Users • Higher Sales
Better Response Time
(External)
• More productive team • Better ability to take decisions
Better Response Time
(Internal)
www.percona.com 15
Direct Costs
Optimized System uses less resources
Decent Database Node on Amazon EC2 - $1000/month
Using less of Nodes, less storage, slower storage are direct savings
www.percona.com 16
Cost Calculation Examples
• Often no real savings achieved
30% Less resources needed for 1-2 nodes
• Can likely use 30 percent less nodes
• $360K out of $1.2M saved yearly
30% Less resources needed for 100 nodes
www.percona.com 17
Take Away
Larger Scale Systems should spend more on Performance Optimization
Even few percent means a lot of $$ on
very high scale
www.percona.com 18
Negative Business Impact
Working on Performance means not working on the new features
Optimized Architecture can be more complicated and slow down pace
www.percona.com 19
Dealing with Negatives
Focus on the performance optimization which does not impact agility first
Consider working with external team
Percona can help!
www.percona.com 20
Lets Look at MySQL in More details!
www.percona.com 21
What MySQL Does
• Selects • Inserts • Deletes • Updates
Processes Queries
www.percona.com 22
What to focus on?
• Making queries run faster
• Using less resources
• Scaling better
Performance Optimization
focused
www.percona.com 23
Transaction Optimization
• Find out which queries it runs
• Optimize them
Specific Application Transaction
www.percona.com 24
General Optimization
• Prioritize them • Optimize them
Look at what
queries Server Runs
www.percona.com 25
Queries
• Get rid of them? • Can we change them to be doing less work?
Are those the
right queries ?
www.percona.com 26
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 27
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.com 28
Schema
• Minor Schema changes
• Data Architecture
Look at Schema
and Queries together
www.percona.com 29
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 30
The Following Also Matter
Infrastructure
Operating System and Configuration
MySQL Version
MySQL Configuration
www.percona.com 31
Optimization Process
Low Hanging Fruit
• MySQL Configuration
• OS Settings • Indexes • Caching
Medium Level
• Infrastructure • OS • MySQL
Version • Storage
Engine
Hard Changes
• Major schema changes
• Application architecture change
www.percona.com 32
Infrastructure Optimization
Scaling Up or Out
• One MySQL Node
• Many MySQL Nodes
Type
• Public Cloud • Private Cloud • Bare Metal
www.percona.com 33
Hardware
CPU
Memory
Disk
Network
www.percona.com 34
CPU
Intel owns the market
2 sockets commonly used
Faster cores or more cores
Turboboost
www.percona.com 35
Memory
Main purpose – Cache
Think Database size vs Memory
Look together with Storage Optimization
www.percona.com 36
Invest in Memory or Storage
www.percona.com 37
Storage
FLASH (SSD) is best!
Directly Attached storage is Fastest
Virtualization, SAN costs performance but brings features
www.percona.com 38
Storage Redundancy
Server Level
• MySQL Replication • Percona XtraDB
Cluster
Local Level
• Storage level (RAID)
• Filesystem level (Local and Distributed)
• Internal Flash Redundancy (RAIN)
www.percona.com 39
Network
Latency
• Distance • Number of
“Hops”
Throughput
• 1Gb is a must, trunking recommended
• 10Gb increasingly affordable
Availability
• Bonding • Multipath
www.percona.com 40
OS Choices
Linux
Server grade
Recent
Supporting MySQL well
www.percona.com 41
OS Tuning
Defaults are good for common workloads
Filesystem: EXT4 or XFS
More Detail http://bit.ly/MySQLonLinux
www.percona.com 42
MySQL Version
New versions typically improve performance
Scalability, Improved Optimizer, etc.
Expect some regressions
Try Percona Server 5.6
www.percona.com 43
MySQL Configuration
Do not run with defaults
Do not ever obsess with tuning
More Details: http://bit.ly/1vth5Cu
www.percona.com 44
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 45 www.percona.com
Tools and The Process
www.percona.com 46
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 47
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 48
Tools
PT-Query-Digest from Percona Toolkit
MySQL Enterprise Monitor
MonYog
VividCortex
Percona Cloud Tools
www.percona.com 49
How to look at the queries
Examples are from Percona Cloud Tools
Other tools are similar
www.percona.com 50
What Queries Server Handles
www.percona.com 51
Server Summary
www.percona.com 52
Query Information
www.percona.com 53
See Change
www.percona.com 54
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 55 55
www.percona.com
Performance Audit w/Support Trial: Start Getting Your MySQL in Shape This
Summer Ø Performance Audit provides a comprehensive review of your MySQL server,
including: • Configuration • Operating system • Hardware configuration • Application architecture • Table design • Indexing and Queries • Capacity • Scaling Potential
Ø Results in a a detailed report that prioritizes how to improve the performance and reliability of your deployment
Ø Plus 3-Month Technical Support Trial to use for questions regarding your audit, help with the follow up action plan, or any other urgent issues with which you need our help
Ø Contact Percona Sales for More Information
www.percona.com 56
Super Saver Rates End on July 5th!
https://www.percona.com/live/europe-amsterdam-2015/
www.percona.com 57
Percona
Support
Managed Services
Consulting
Software
www.percona.com 58 www.percona.com
Peter Zaitsev [email protected]
https://www.linkedin.com/in/peterzaitsev
Thank You!