Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

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

1,501 views

Published on

Если вы используете MySQL, то для вас, скорее всего, важна производительность. Данный доклад посвящен теме производительности, и поэтому его стоит послушать.
В рамках доклада будет рассмотрен практический метод оптимизации производительности MySQL, который большей частью применим для других баз данных тоже.
Из доклада вы узнаете:
+ о том, как измерять производительность, учитывая требования пользователей и бизнеса;
+ о том, как ставить цели по производительности;
+ о том, как наиболее эффективно использовать ресурсы разработчиков и администраторов баз данных для получения максимального результата.

Published in: Engineering
  • Be the first to comment

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

  1. 1. Peter Zaitsev, CEO, Percona November 3, 2015 Highload++ Moscow, Russia Practical MySQL Performance Optimization
  2. 2. 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
  3. 3. 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
  4. 4. www.percona.com4 First Things First MySQL Performance does not Matter!
  5. 5. www.percona.com5 What DOES Matter? Application Performance!
  6. 6. www.percona.com6 Even More so Application Performance Always Matters!
  7. 7. www.percona.com7 Take Away Performance Problems might not be MySQL Performance Solutions might not be with MySQL
  8. 8. www.percona.com8 Many “Tools” • MongoDB • Cassandra • Hadoop • Elastic Search • Redis Use the best Tool for the job
  9. 9. www.percona.com9 Say Performance Think about Response Time
  10. 10. www.percona.com10 Related Issues Stability Scalability Efficiency
  11. 11. www.percona.com11 Scalability? •Load •Data Size •Infrastructure Scalability with:
  12. 12. www.percona.com12 Performance “Sandbags” Security Manageability Compatibility Compliance Ease of use by Developers
  13. 13. www.percona.com13 “Good Enough” You can always improve your system. Know when to stop.
  14. 14. www.percona.com14 What MySQL Does •Selects •Inserts •Deletes •Updates Processes Queries
  15. 15. www.percona.com15 What to focus on? • Making queries run faster • Using less resources • Scaling better Performance Optimization focused
  16. 16. www.percona.com16 Transaction Optimization •Find out which queries it runs •Optimize them Specific Application Transaction
  17. 17. www.percona.com17 General Optimization •Prioritize them •Optimize them Look at what queries Server Runs
  18. 18. www.percona.com18 Queries •Get rid of them? •Can we change them to be doing less work? Are those the right queries ?
  19. 19. 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
  20. 20. 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
  21. 21. www.percona.com21 Schema •Minor Schema changes •Data Architecture Look at Schema and Queries together
  22. 22. 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
  23. 23. www.percona.com23 The Following Also Matter Infrastructure Operating System and Configuration MySQL Version MySQL Configuration
  24. 24. 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
  25. 25. www.percona.com25 Infrastructure Scaling Up or Out • One MySQL Node • Many MySQL Nodes Type • Public Cloud • Private Cloud • Bare Metal
  26. 26. www.percona.com26 Hardware CPU Memory Disk Network
  27. 27. www.percona.com27 CPU Intel owns the market 2 sockets commonly used Faster cores or more cores Turboboost
  28. 28. www.percona.com28 Memory Main purpose – Cache Think Database size vs Memory Look together with Storage Optimization
  29. 29. www.percona.com29 Invest in Memory or Storage
  30. 30. www.percona.com30 Storage Types • Directly Attached • SAN • NAS • Virtualized Flash • PCI-E • SATA “Disks” • TLC, MLC, eMLC, SLC RAID • Hardware • Software • Filesystem
  31. 31. www.percona.com31 Network Latency • Distance • Number of “Hops” Throughput • 1Gb is a must, trunking recommended • 10Gb increasingly affordable Availability • Bonding • Multipath
  32. 32. www.percona.com32 OS Choices Linux Server grade Recent Supporting MySQL well
  33. 33. www.percona.com33 OS Tuning Defaults are good for common workloads Filesystem: EXT4 or XFS More Detail http://bit.ly/MySQLonLinux
  34. 34. 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
  35. 35. www.percona.com35 MySQL Configuration Do not run with defaults Do not ever obsess with tuning More Details: http://bit.ly/1vth5Cu
  36. 36. 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
  37. 37. www.percona.com37 www.percona.com Tools and The Process
  38. 38. 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
  39. 39. 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
  40. 40. www.percona.com40 Tools PT-Query-Digest from Percona Toolkit MySQL Enterprise Monitor MonYog VividCortex Graphite
  41. 41. 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
  42. 42. www.percona.com42 Graphite Example
  43. 43. www.percona.com43 Query Profile
  44. 44. www.percona.com44 Server Profile
  45. 45. 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
  46. 46. 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/ 4 6
  47. 47. 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 4 7
  48. 48. www.percona.com48 www.percona.com Peter Zaitsev pz@percona.com P.S We’re Hiring http://bit.ly/PerconaJobs Thank You!

×