SlideShare ist ein Scribd-Unternehmen logo
1 von 29
MySQL Performance
  It ain’t just indexing!
Overview

You’ve done indexing

You’ve optimised queries

You need more oomph

You’ll need to dig around a bit more

MySQL config and server admin
Optimisation Costs
Consider cheaper alternatives

Assess the situation

  How long will current system last?

  How much effort to correct it?

  Can I hack in some performance
  later (Probably “Yes”)
Optimisation Options
 Switch to InnoDB

   Avoid table locks

 CPU / RAM is cheap

 Developer / Admin time is not

 Process heavy queries asynchronously

 Use a replicated slave (Long queries)
In-MySQL Solutions
Clever indexing

Query and Dataset reorganisation

Denormalise / Summarised data

Use “SELECT *” sparingly

Subqueries can be faster

Benchmark differences
In-MySQL Solutions



In-Memory temporary tables

Stored procedures are super fast
That didn’t work...
Time to look at MySQL config

Assess what can be done with the OS

OS can hit these walls:

  CPU (Run queue, Load average)

  Memory (Cheap fix)

  Disk (Minimise this if possible)
What else?
MySQL is usually memory or disk bound

  Memory bound can lead to disk bound

PHP is normally CPU bound

  Mostly waiting on a disk or DB

  Profile your app - How long waiting
  for DB?
Is my MySQL app
   Memory Bound?


Most definitely

Default my.cnf is probably okay
Where can I improve?
 SHOW GLOBAL STATUS

   Good insight to where to tweak

   created_tmp_tables vs
   created_tmp_disk_tables

   threads_created

   sort_merge_passes
Basic OS Theory

If the operation doesn’t fit in
memory

The operation swaps to disk

PHP and DB on the same disk

Not a good idea for performance
my.cnf


Quick guides on my.cnf

  http://bit.ly/VKmcQ

  http://bit.ly/3pqQc
my.cnf
Heap sizes

  max_heap_size >=
  max_temp_table_size

  Tweak... SHOW GLOBAL STATUS LIKE
  ‘Created_%’

  Compare before and after values
  for temporary tables
Processor Crack
Every process is competing for IO

“top” is a great tool for checking

Shows %age of run queue that is IO
Are we swapping?

Swapping is bad...
mkay?

Swapping != lots
of disk IO

Its compsumption
of Memory
iostat
Shows IO activity

  Bytes read, written

Easy to see IO
iostat
Only works on a per-partition basis

Plan your disk structure!!

Separate heavy IO areas

  /var/lib/mysql

  /var/www

  /tmp
atop
top. On CRACK.

Per-process IO stats

Similar output to iostat
View disk activity

/proc/sys/vm/block_dump

  echo “1” to this file

  dmesg buffer now contains low
  level disk activity information

  Its noisy / long
What did I learn?

Try to avoid MySQL being disk bound

  Increase buffer pools

  Increase max temp table size

  Research why MySQL is slow
I did all that...

Use tools to identify disk access

  Check for high swap

  iostat

  atop

  block_dump
Show me the money!
       AKA: I’m bored,
  just show me the solution
PHP Fixes
           APC

Opcode cache => APC

Free optimisation

apc.stat = 0 (don’t check mtime)
PHP Fixes
         Memcache

Great for distributed environments

Use for configs

Faster than MySQL query cache
PHP Fixes
         Whaaaa?

I thought we were talking about MySQL

Limit PHP’s access to the disk

Give MySQL free reign when needed
Reduce memory usage
.. or get more memory (its cheap!)

Reduce apache min spares

  Or get a better http server

  I suggest Nginx!

OS Swap tendency: /proc/sys/vm/
swapiness
Disk mounting
Use the “noatime” option for mounts

MySQL - No big deal

Web server

  JACKPOT

  Every read results in a small
  write
noatime
Benefits

  Only read when we go to read

Whatever the opposite of benefit is

  We don’t know when files were last
  accessed

  Acceptable casualties?
Its over!
You may now emerge from your semi-comatose
    in-chair sleep, and ask questions.

Weitere Àhnliche Inhalte

Was ist angesagt?

Drupal performance
Drupal performanceDrupal performance
Drupal performance
Piyuesh Kumar
 
web optimizations
web optimizationsweb optimizations
web optimizations
Georgi Tachev
 
Growing MongoDB on AWS
Growing MongoDB on AWSGrowing MongoDB on AWS
Growing MongoDB on AWS
colinthehowe
 

Was ist angesagt? (18)

Mysql talk
Mysql talkMysql talk
Mysql talk
 
High Availabiltity & Replica Sets with mongoDB
High Availabiltity & Replica Sets with mongoDBHigh Availabiltity & Replica Sets with mongoDB
High Availabiltity & Replica Sets with mongoDB
 
Drupal performance
Drupal performanceDrupal performance
Drupal performance
 
web optimizations
web optimizationsweb optimizations
web optimizations
 
WordPress.org & Optimizing Security for your WordPress sites
WordPress.org & Optimizing Security for your WordPress sitesWordPress.org & Optimizing Security for your WordPress sites
WordPress.org & Optimizing Security for your WordPress sites
 
Intro to MySQL Master Slave Replication
Intro to MySQL Master Slave ReplicationIntro to MySQL Master Slave Replication
Intro to MySQL Master Slave Replication
 
High Performance Wordpress: “Faster, Cheaper, Easier : Pick Three”
High Performance Wordpress: “Faster, Cheaper, Easier : Pick Three”High Performance Wordpress: “Faster, Cheaper, Easier : Pick Three”
High Performance Wordpress: “Faster, Cheaper, Easier : Pick Three”
 
Nginx [engine x] and you (and WordPress)
Nginx [engine x] and you (and WordPress)Nginx [engine x] and you (and WordPress)
Nginx [engine x] and you (and WordPress)
 
Mysql data replication
Mysql data replicationMysql data replication
Mysql data replication
 
Apache Mesos Distributed Computing Talk
Apache Mesos Distributed Computing Talk Apache Mesos Distributed Computing Talk
Apache Mesos Distributed Computing Talk
 
Growing MongoDB on AWS
Growing MongoDB on AWSGrowing MongoDB on AWS
Growing MongoDB on AWS
 
SSDs are Awesome
SSDs are AwesomeSSDs are Awesome
SSDs are Awesome
 
WooCommerce System Status
WooCommerce System StatusWooCommerce System Status
WooCommerce System Status
 
Shell commands are fun
Shell commands are funShell commands are fun
Shell commands are fun
 
Why does my jenkins freeze sometimes and what can I do about it?
Why does my jenkins freeze sometimes and what can I do about it?Why does my jenkins freeze sometimes and what can I do about it?
Why does my jenkins freeze sometimes and what can I do about it?
 
Basic Knowledge on MySql Replication
Basic Knowledge on MySql ReplicationBasic Knowledge on MySql Replication
Basic Knowledge on MySql Replication
 
Basics of Logical Replication,Streaming replication vs Logical Replication ,U...
Basics of Logical Replication,Streaming replication vs Logical Replication ,U...Basics of Logical Replication,Streaming replication vs Logical Replication ,U...
Basics of Logical Replication,Streaming replication vs Logical Replication ,U...
 
WordCamp RVA
WordCamp RVAWordCamp RVA
WordCamp RVA
 

Andere mochten auch

Performance Schema in MySQL (Danil Zburivsky)
Performance Schema in MySQL (Danil Zburivsky)Performance Schema in MySQL (Danil Zburivsky)
Performance Schema in MySQL (Danil Zburivsky)
Ontico
 
Mysql tech day_paris_ps_and_sys
Mysql tech day_paris_ps_and_sysMysql tech day_paris_ps_and_sys
Mysql tech day_paris_ps_and_sys
Mark Leith
 
My sql 5.7-upcoming-changes-v2
My sql 5.7-upcoming-changes-v2My sql 5.7-upcoming-changes-v2
My sql 5.7-upcoming-changes-v2
Morgan Tocker
 
MySQL 5.6 - Operations and Diagnostics Improvements
MySQL 5.6 - Operations and Diagnostics ImprovementsMySQL 5.6 - Operations and Diagnostics Improvements
MySQL 5.6 - Operations and Diagnostics Improvements
Morgan Tocker
 
MySQL For Linux Sysadmins
MySQL For Linux SysadminsMySQL For Linux Sysadmins
MySQL For Linux Sysadmins
Morgan Tocker
 

Andere mochten auch (20)

Performance Schema in MySQL (Danil Zburivsky)
Performance Schema in MySQL (Danil Zburivsky)Performance Schema in MySQL (Danil Zburivsky)
Performance Schema in MySQL (Danil Zburivsky)
 
The MySQL Performance Schema & New SYS Schema
The MySQL Performance Schema & New SYS SchemaThe MySQL Performance Schema & New SYS Schema
The MySQL Performance Schema & New SYS Schema
 
MySQL Troubleshooting with the Performance Schema
MySQL Troubleshooting with the Performance SchemaMySQL Troubleshooting with the Performance Schema
MySQL Troubleshooting with the Performance Schema
 
MySQL Oslayer performace optimization
MySQL  Oslayer performace optimizationMySQL  Oslayer performace optimization
MySQL Oslayer performace optimization
 
An Overview to MySQL SYS Schema
An Overview to MySQL SYS Schema An Overview to MySQL SYS Schema
An Overview to MySQL SYS Schema
 
Performance Schema for MySQL Troubleshooting
 Performance Schema for MySQL Troubleshooting Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
 
MySQL Monitoring Mechanisms
MySQL Monitoring MechanismsMySQL Monitoring Mechanisms
MySQL Monitoring Mechanisms
 
MySQL User Camp: GTIDs
MySQL User Camp: GTIDsMySQL User Camp: GTIDs
MySQL User Camp: GTIDs
 
MySQL User Camp: MySQL Cluster
MySQL User Camp: MySQL ClusterMySQL User Camp: MySQL Cluster
MySQL User Camp: MySQL Cluster
 
Mysql tech day_paris_ps_and_sys
Mysql tech day_paris_ps_and_sysMysql tech day_paris_ps_and_sys
Mysql tech day_paris_ps_and_sys
 
MySQL 5.7 New Features for Developers
MySQL 5.7 New Features for DevelopersMySQL 5.7 New Features for Developers
MySQL 5.7 New Features for Developers
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
 
Open source India - MySQL Labs: Multi-Source Replication
Open source India - MySQL Labs: Multi-Source ReplicationOpen source India - MySQL Labs: Multi-Source Replication
Open source India - MySQL Labs: Multi-Source Replication
 
MySQL Query Optimization.
MySQL Query Optimization.MySQL Query Optimization.
MySQL Query Optimization.
 
My sql 5.7-upcoming-changes-v2
My sql 5.7-upcoming-changes-v2My sql 5.7-upcoming-changes-v2
My sql 5.7-upcoming-changes-v2
 
Performance Schema for MySQL troubleshooting
Performance Schema for MySQL troubleshootingPerformance Schema for MySQL troubleshooting
Performance Schema for MySQL troubleshooting
 
MySQL 5.6 - Operations and Diagnostics Improvements
MySQL 5.6 - Operations and Diagnostics ImprovementsMySQL 5.6 - Operations and Diagnostics Improvements
MySQL 5.6 - Operations and Diagnostics Improvements
 
MySQL For Linux Sysadmins
MySQL For Linux SysadminsMySQL For Linux Sysadmins
MySQL For Linux Sysadmins
 
MySQL: Indexing for Better Performance
MySQL: Indexing for Better PerformanceMySQL: Indexing for Better Performance
MySQL: Indexing for Better Performance
 
Instrumenting plugins for Performance Schema
Instrumenting plugins for Performance SchemaInstrumenting plugins for Performance Schema
Instrumenting plugins for Performance Schema
 

Ähnlich wie MySQL Performance - SydPHP October 2011

Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
Joseph Scott
 
Drupal Backend Performance and Scalability
Drupal Backend Performance and ScalabilityDrupal Backend Performance and Scalability
Drupal Backend Performance and Scalability
Ashok Modi
 
MySQL Server Settings Tuning
MySQL Server Settings TuningMySQL Server Settings Tuning
MySQL Server Settings Tuning
guest5ca94b
 
Scalable Web Architectures: Common Patterns and Approaches - Web 2.0 Expo NYC
Scalable Web Architectures: Common Patterns and Approaches - Web 2.0 Expo NYCScalable Web Architectures: Common Patterns and Approaches - Web 2.0 Expo NYC
Scalable Web Architectures: Common Patterns and Approaches - Web 2.0 Expo NYC
Cal Henderson
 
vSphere APIs for performance monitoring
vSphere APIs for performance monitoringvSphere APIs for performance monitoring
vSphere APIs for performance monitoring
Alan Renouf
 

Ähnlich wie MySQL Performance - SydPHP October 2011 (20)

Cassandra as Memcache
Cassandra as MemcacheCassandra as Memcache
Cassandra as Memcache
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
 
Lamp Stack Optimization
Lamp Stack OptimizationLamp Stack Optimization
Lamp Stack Optimization
 
Drupal Backend Performance and Scalability
Drupal Backend Performance and ScalabilityDrupal Backend Performance and Scalability
Drupal Backend Performance and Scalability
 
DrupalCampLA 2011: Drupal backend-performance
DrupalCampLA 2011: Drupal backend-performanceDrupalCampLA 2011: Drupal backend-performance
DrupalCampLA 2011: Drupal backend-performance
 
Cómo se diseña una base de datos que pueda ingerir mås de cuatro millones de ...
Cómo se diseña una base de datos que pueda ingerir mås de cuatro millones de ...Cómo se diseña una base de datos que pueda ingerir mås de cuatro millones de ...
Cómo se diseña una base de datos que pueda ingerir mås de cuatro millones de ...
 
Functional? Reactive? Why?
Functional? Reactive? Why?Functional? Reactive? Why?
Functional? Reactive? Why?
 
Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011
 
MySQL Server Settings Tuning
MySQL Server Settings TuningMySQL Server Settings Tuning
MySQL Server Settings Tuning
 
Running MySQL on Linux
Running MySQL on LinuxRunning MySQL on Linux
Running MySQL on Linux
 
phptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorialphptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorial
 
IMC Summit 2016 Breakout - Per Minoborg - Work with Multiple Hot Terabytes in...
IMC Summit 2016 Breakout - Per Minoborg - Work with Multiple Hot Terabytes in...IMC Summit 2016 Breakout - Per Minoborg - Work with Multiple Hot Terabytes in...
IMC Summit 2016 Breakout - Per Minoborg - Work with Multiple Hot Terabytes in...
 
Caching Data For Performance
Caching Data For PerformanceCaching Data For Performance
Caching Data For Performance
 
Sql server scalability fundamentals
Sql server scalability fundamentalsSql server scalability fundamentals
Sql server scalability fundamentals
 
Scalable Web Architectures: Common Patterns and Approaches - Web 2.0 Expo NYC
Scalable Web Architectures: Common Patterns and Approaches - Web 2.0 Expo NYCScalable Web Architectures: Common Patterns and Approaches - Web 2.0 Expo NYC
Scalable Web Architectures: Common Patterns and Approaches - Web 2.0 Expo NYC
 
MNPHP Scalable Architecture 101 - Feb 3 2011
MNPHP Scalable Architecture 101 - Feb 3 2011MNPHP Scalable Architecture 101 - Feb 3 2011
MNPHP Scalable Architecture 101 - Feb 3 2011
 
vSphere APIs for performance monitoring
vSphere APIs for performance monitoringvSphere APIs for performance monitoring
vSphere APIs for performance monitoring
 
FOWA Scaling The Lamp Stack Workshop
FOWA Scaling The Lamp Stack WorkshopFOWA Scaling The Lamp Stack Workshop
FOWA Scaling The Lamp Stack Workshop
 
Vmfs
VmfsVmfs
Vmfs
 

Mehr von Graham Weldon

20130714 php matsuri - highly available php
20130714   php matsuri - highly available php20130714   php matsuri - highly available php
20130714 php matsuri - highly available php
Graham Weldon
 
SydPHP May 2012 - Deployment
SydPHP May 2012 - DeploymentSydPHP May 2012 - Deployment
SydPHP May 2012 - Deployment
Graham Weldon
 
Nginx in production
Nginx in productionNginx in production
Nginx in production
Graham Weldon
 

Mehr von Graham Weldon (20)

HackLang Introduction
HackLang IntroductionHackLang Introduction
HackLang Introduction
 
20130714 php matsuri - highly available php
20130714   php matsuri - highly available php20130714   php matsuri - highly available php
20130714 php matsuri - highly available php
 
CakePHP and Open Source - Newcastle University
CakePHP and Open Source - Newcastle UniversityCakePHP and Open Source - Newcastle University
CakePHP and Open Source - Newcastle University
 
SydPHP March 2012 Meetup
SydPHP March 2012 MeetupSydPHP March 2012 Meetup
SydPHP March 2012 Meetup
 
SydPHP June 2012 - GovHack overview
SydPHP June 2012 - GovHack overviewSydPHP June 2012 - GovHack overview
SydPHP June 2012 - GovHack overview
 
SydPHP April 2012
SydPHP April 2012SydPHP April 2012
SydPHP April 2012
 
SydPHP May 2012 - Deployment
SydPHP May 2012 - DeploymentSydPHP May 2012 - Deployment
SydPHP May 2012 - Deployment
 
Building 3D apps with Javascript
Building 3D apps with JavascriptBuilding 3D apps with Javascript
Building 3D apps with Javascript
 
An introduction to Titanium
An introduction to TitaniumAn introduction to Titanium
An introduction to Titanium
 
PHP 5.4 - Begin your love affair with traits
PHP 5.4 - Begin your love affair with traitsPHP 5.4 - Begin your love affair with traits
PHP 5.4 - Begin your love affair with traits
 
CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011
 
Nginx in production
Nginx in productionNginx in production
Nginx in production
 
The business behind open source
The business behind open sourceThe business behind open source
The business behind open source
 
CakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your worldCakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your world
 
CakePHP - The Path to 2.0
CakePHP - The Path to 2.0CakePHP - The Path to 2.0
CakePHP - The Path to 2.0
 
CakePHP Tutorial - OSDC 2010
CakePHP Tutorial - OSDC 2010CakePHP Tutorial - OSDC 2010
CakePHP Tutorial - OSDC 2010
 
Debugging and Profiling PHP
Debugging and Profiling PHPDebugging and Profiling PHP
Debugging and Profiling PHP
 
OSDC LIghtning Talk - Context Free Art
OSDC LIghtning Talk - Context Free ArtOSDC LIghtning Talk - Context Free Art
OSDC LIghtning Talk - Context Free Art
 
Re-imagining CakePHP (OSDC 2010)
Re-imagining CakePHP (OSDC 2010)Re-imagining CakePHP (OSDC 2010)
Re-imagining CakePHP (OSDC 2010)
 
Re-imaginging CakePHP
Re-imaginging CakePHPRe-imaginging CakePHP
Re-imaginging CakePHP
 

KĂŒrzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

KĂŒrzlich hochgeladen (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 

MySQL Performance - SydPHP October 2011

  • 1. MySQL Performance It ain’t just indexing!
  • 2. Overview You’ve done indexing You’ve optimised queries You need more oomph You’ll need to dig around a bit more MySQL config and server admin
  • 3. Optimisation Costs Consider cheaper alternatives Assess the situation How long will current system last? How much effort to correct it? Can I hack in some performance later (Probably “Yes”)
  • 4. Optimisation Options Switch to InnoDB Avoid table locks CPU / RAM is cheap Developer / Admin time is not Process heavy queries asynchronously Use a replicated slave (Long queries)
  • 5. In-MySQL Solutions Clever indexing Query and Dataset reorganisation Denormalise / Summarised data Use “SELECT *” sparingly Subqueries can be faster Benchmark differences
  • 6. In-MySQL Solutions In-Memory temporary tables Stored procedures are super fast
  • 7. That didn’t work... Time to look at MySQL config Assess what can be done with the OS OS can hit these walls: CPU (Run queue, Load average) Memory (Cheap fix) Disk (Minimise this if possible)
  • 8. What else? MySQL is usually memory or disk bound Memory bound can lead to disk bound PHP is normally CPU bound Mostly waiting on a disk or DB Profile your app - How long waiting for DB?
  • 9. Is my MySQL app Memory Bound? Most definitely Default my.cnf is probably okay
  • 10. Where can I improve? SHOW GLOBAL STATUS Good insight to where to tweak created_tmp_tables vs created_tmp_disk_tables threads_created sort_merge_passes
  • 11. Basic OS Theory If the operation doesn’t fit in memory The operation swaps to disk PHP and DB on the same disk Not a good idea for performance
  • 12. my.cnf Quick guides on my.cnf http://bit.ly/VKmcQ http://bit.ly/3pqQc
  • 13. my.cnf Heap sizes max_heap_size >= max_temp_table_size Tweak... SHOW GLOBAL STATUS LIKE ‘Created_%’ Compare before and after values for temporary tables
  • 14. Processor Crack Every process is competing for IO “top” is a great tool for checking Shows %age of run queue that is IO
  • 15. Are we swapping? Swapping is bad... mkay? Swapping != lots of disk IO Its compsumption of Memory
  • 16. iostat Shows IO activity Bytes read, written Easy to see IO
  • 17. iostat Only works on a per-partition basis Plan your disk structure!! Separate heavy IO areas /var/lib/mysql /var/www /tmp
  • 18. atop top. On CRACK. Per-process IO stats Similar output to iostat
  • 19. View disk activity /proc/sys/vm/block_dump echo “1” to this file dmesg buffer now contains low level disk activity information Its noisy / long
  • 20. What did I learn? Try to avoid MySQL being disk bound Increase buffer pools Increase max temp table size Research why MySQL is slow
  • 21. I did all that... Use tools to identify disk access Check for high swap iostat atop block_dump
  • 22. Show me the money! AKA: I’m bored, just show me the solution
  • 23. PHP Fixes APC Opcode cache => APC Free optimisation apc.stat = 0 (don’t check mtime)
  • 24. PHP Fixes Memcache Great for distributed environments Use for configs Faster than MySQL query cache
  • 25. PHP Fixes Whaaaa? I thought we were talking about MySQL Limit PHP’s access to the disk Give MySQL free reign when needed
  • 26. Reduce memory usage .. or get more memory (its cheap!) Reduce apache min spares Or get a better http server I suggest Nginx! OS Swap tendency: /proc/sys/vm/ swapiness
  • 27. Disk mounting Use the “noatime” option for mounts MySQL - No big deal Web server JACKPOT Every read results in a small write
  • 28. noatime Benefits Only read when we go to read Whatever the opposite of benefit is We don’t know when files were last accessed Acceptable casualties?
  • 29. Its over! You may now emerge from your semi-comatose in-chair sleep, and ask questions.

Hinweis der Redaktion

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n