SlideShare una empresa de Scribd logo
1 de 83
Descargar para leer sin conexión
The most common
   MySQL scalability
                 mistakes,
and how to avoid them.
                          2010.08



                                                    Ronald Bradford
                                                     www.RonaldBradford.com
  The most common MySQL scalability mistakes, and how to avoid them.
                                                    @RonaldBradford #surgecon
9
The most common MySQL scalability mistakes, and how to avoid them.
                                                  @RonaldBradford #surgecon
PROBLEM

My website seems to
freeze or responds
randomly?



  The most common MySQL scalability mistakes, and how to avoid them.
                                                    @RonaldBradford #surgecon
CAUSE

The default MyISAM
storage engine uses
exclusive table locks for
DML.


   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
SOLUTION
Optimize blocking query
performance
Use a transactional engine
with MVCC and row based
locking to address the
LOCKING issue
   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
EXAMPLE
Crazy end user report that selects
all customer, order, order lines and
order history data and performs
poor joins. This takes shared read
locks blocking future write locks
then future reads.


    The most common MySQL scalability mistakes, and how to avoid them.
                                                      @RonaldBradford #surgecon
WHY
MySQL is unique in that it offers
different mechanisms for storing
and retrieving data, each with
strengths and weaknesses.
The DEFAULT is not always the
best.

    The most common MySQL scalability mistakes, and how to avoid them.
                                                      @RonaldBradford #surgecon
HOW
 MySQL PROCESSLIST
   Blocked have State = Locked
   Blocker - Same table, older Time

mysql> SHOW PROCESSLIST;
+----+------+-----------+-------+---------+------+------------+---------------
| Id | User | Host      | db    | Command | Time | State      | Info
+----+------+-----------+-------+---------+------+------------+---------------
| 13 | root | localhost | odtug | Query   | 144 | User sleep | UPDATE test1 ...
| 14 | root | localhost | odtug | Query   | 116 | Locked      | select * from test1
| 15 | root | localhost | odtug | Query   |   89 | Locked     | select * from test1




           The most common MySQL scalability mistakes, and how to avoid them.
                                                             @RonaldBradford #surgecon
HOW
Optimize Blocker
  Indexes
  Limit query
  Summary table
  Change storage engine

    The most common MySQL scalability mistakes, and how to avoid them.
                                                      @RonaldBradford #surgecon
8
The most common MySQL scalability mistakes, and how to avoid them.
                                                  @RonaldBradford #surgecon
PROBLEM

Why is my database so
large?




  The most common MySQL scalability mistakes, and how to avoid them.
                                                    @RonaldBradford #surgecon
SOLUTION

Don’t store large static
objects in the database




   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
EXAMPLE
80% of data is email content/
attachments
60% of data is PDF documents
30% of data is uncompressed large
XML objects


    The most common MySQL scalability mistakes, and how to avoid them.
                                                      @RonaldBradford #surgecon
WHY

Maximize memory usage
for important data
Reduce database recovery
time

   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
HOW
Compress large text data
   90% saving on XML data
Store static data in files
   Avoids DB handling overhead



    The most common MySQL scalability mistakes, and how to avoid them.
                                                      @RonaldBradford #surgecon
HOW
    Table Size per schema
# Schema Table Usage
SELECT   table_schema,table_name,engine,row_format, table_rows, avg_row_length,
         (data_length+index_length)/1024/1024 as total_mb,
         (data_length)/1024/1024 as data_mb,
         (index_length)/1024/1024 as index_mb,
         CURDATE() AS today
FROM     information_schema.tables
WHERE    table_schema = DATABASE()
ORDER BY 7 DESC;




             The most common MySQL scalability mistakes, and how to avoid them.
                                                               @RonaldBradford #surgecon
7
The most common MySQL scalability mistakes, and how to avoid them.
                                                  @RonaldBradford #surgecon
PROBLEM

I can't access my website?




   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
TRUE STORY




The most common MySQL scalability mistakes, and how to avoid them.
                                                  @RonaldBradford #surgecon
TRUE STORY
Question:




     The most common MySQL scalability mistakes, and how to avoid them.
                                                       @RonaldBradford #surgecon
TRUE STORY
Question:
 How do you know when your server
 is down or not accessible?




     The most common MySQL scalability mistakes, and how to avoid them.
                                                       @RonaldBradford #surgecon
TRUE STORY
Question:
 How do you know when your server
 is down or not accessible?
Answer:



     The most common MySQL scalability mistakes, and how to avoid them.
                                                       @RonaldBradford #surgecon
TRUE STORY
Question:
 How do you know when your server
 is down or not accessible?
Answer:
 The users will let us know.


     The most common MySQL scalability mistakes, and how to avoid them.
                                                       @RonaldBradford #surgecon
SOLUTION
Monitoring
Alerting
Dashboard
Status Site



    The most common MySQL scalability mistakes, and how to avoid them.
                                                      @RonaldBradford #surgecon
HOW
Monitoring/Alerting
  Graphical
  Historical
  Necessary
  Generally missing/incomplete
  Useless for real-time analysis
    The most common MySQL scalability mistakes, and how to avoid them.
                                                      @RonaldBradford #surgecon
HOW
Dashboard
 The state of NOW
 Sampling at 1s/3s/5s
   e.g. 0.1% of throughput



   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
HOW
Instrumentation
 Important to business viability
   e.g. orders per minute
   page load time
 Seamless implementation
   i.e. no code changes to view real-time
   extensible
   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
HOW
Have a status website
 allow for comments (e.g. blog)
Have a public dashboard website

Host them somewhere else!

   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
6
The most common MySQL scalability mistakes, and how to avoid them.
                                                  @RonaldBradford #surgecon
PROBLEM

My replication slave can't
keep up?




   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
SOLUTION

Know the weakest link(s)
of MySQL replication and
don't exceed that,
or cheat.


   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
WHY

If replication can't catchup,
slaves are useless.
Backup & recovery may
also suffer.

   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
HOW
Master
  DML Statement
  Write Data/Redo Log
  Write Binary Log
  Return OK to client



         The most common MySQL scalability mistakes, and how to avoid them.
                                                           @RonaldBradford #surgecon
HOW
Slave
  Detect master log change
  Retrieve binary log entry
  Write relay log (IO_THREAD)
  Read relay log
  Apply DML (SQL_THREAD)
  Write Data/redo log

        The most common MySQL scalability mistakes, and how to avoid them.
                                                          @RonaldBradford #surgecon
HOW
Clever workarounds
  Restrict queries executed
    --ignore
  Different storage engines
  Different index structures


    The most common MySQL scalability mistakes, and how to avoid them.
                                                      @RonaldBradford #surgecon
EXPERT TIP
Cheating
  RAID 0 (large number of slaves)
  Pre fetch thread




   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
5
The most common MySQL scalability mistakes, and how to avoid them.
                                                  @RonaldBradford #surgecon
PROBLEM

My server has crashed with
a hard drive failure




   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
TRUE STORY
Question:
 Have you ever performed a database recovery?

Answer:
 No, why?




      The most common MySQL scalability mistakes, and how to avoid them.
                                                        @RonaldBradford #surgecon
TRUE STORY
Consultant:
 Do you know that your daily backups only
 recover the data up to that time, e.g. 1am. You
 know you have lost all your sales and changes
 since then.

Customer:
 No, I didn’t know that.

      The most common MySQL scalability mistakes, and how to avoid them.
                                                        @RonaldBradford #surgecon
SOLUTION
Have a DR Plan
  Documented
  Tested
  Timed
  Verified - End to End

   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
HOW
Do you pass the MySQL backup/
recovery quiz?


http://rb42.com/mysql-backup-quiz



    The most common MySQL scalability mistakes, and how to avoid them.
                                                      @RonaldBradford #surgecon
QUIZ
1.  Do you have MySQL backups in place?
2.  Do you backup ALL your MySQL data?
3.  Do you have consistent MySQL backups?
4.  Do you have backups that include both static snapshot and point in
    time transactions?
 5. Do you review your backup logs EVERY SINGLE day or have tested
    backup monitoring in place?
 6. Do you perform a test recovery of your static backup?
 7. Do you perform a test recovery to point in time?
 8. Do you time your backup and recovery process and review over time?
 9. Do you have off-site copies of your backups?
10. Do you backup your primary binary logs?

                                            http://rb42.com/mysql-backup-quiz

           The most common MySQL scalability mistakes, and how to avoid them.
                                                             @RonaldBradford #surgecon
4
The most common MySQL scalability mistakes, and how to avoid them.
                                                  @RonaldBradford #surgecon
PROBLEM

Why is my database
executing 1,200 qps
for 50 users?



   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
SOLUTION

Determine what queries
are running and why they
are running?



   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
CAUSE

Excessive SQL statements
 Duplicate
 Redundant
 Cachable
 Row at a time (RAT)
   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
WHY

Reducing SQL load both
improves performance now
and provides greater
capacity as you scale


  The most common MySQL scalability mistakes, and how to avoid them.
                                                    @RonaldBradford #surgecon
EXAMPLE
SELECT   option_name,   option_value FROM wp_options WHERE autoload = 'yes'
SELECT   option_value   FROM wp_options WHERE option_name = 'aiosp_title_format' LIMIT   1
SELECT   option_value   FROM wp_options WHERE option_name = 'ec3_show_only_even' LIMIT   1
SELECT   option_value   FROM wp_options WHERE option_name = 'ec3_num_months' LIMIT 1
SELECT   option_value   FROM wp_options WHERE option_name = 'ec3_day_length' LIMIT 1
SELECT   option_value   FROM wp_options WHERE option_name = 'ec3_hide_event_box' LIMIT   1
SELECT   option_value   FROM wp_options WHERE option_name = 'ec3_advanced' LIMIT 1
SELECT   option_value   FROM wp_options WHERE option_name = 'ec3_navigation' LIMIT 1
SELECT   option_value   FROM wp_options WHERE option_name = 'ec3_disable_popups' LIMIT   1
SELECT   option_value   FROM wp_options WHERE option_name = 'sidebars_widgets' LIMIT 1




                               http://ronaldbradford.com/blog/we-need-more-cats-2009-08-22/


               The most common MySQL scalability mistakes, and how to avoid them.
                                                                   @RonaldBradford #surgecon
EXAMPLE
  SELECT    *   FROM   activities_theme          WHERE    theme_parent_id=0
  SELECT    *   FROM   activities_theme          WHERE    theme_parent_id=1
  SELECT    *   FROM   activities_theme          WHERE    theme_parent_id=2
  SELECT    *   FROM   activities_theme          WHERE    theme_parent_id=11
  SELECT    *   FROM   activities_theme          WHERE    theme_parent_id=16


  SELECT *
  FROM   activities_theme
  WHERE theme_parent_id in                (0,1,2,11,16)




http://ronaldbradford.com/blog/optimizing-sql-performance-the-art-of-elimination-2010-07-08/


                The most common MySQL scalability mistakes, and how to avoid them.
                                                                  @RonaldBradford #surgecon
EXAMPLE
  5   Query   SELECT   *   FROM   `artist`
  5   Query   SELECT   *   FROM   `artist`
  5   Query   SELECT   *   FROM   `artist`
  5   Query   SELECT   *   FROM   `artist`
  5   Query   SELECT   *   FROM   `artist`
  5   Query   SELECT   *   FROM   `artist` WHERE (ArtistID = 196 )
  5   Query   SELECT   *   FROM   `artist` WHERE (ArtistID = 2188 )
  5   Query   SELECT   *   FROM   `artist`
  5   Query   SELECT   *   FROM   `artist`
  5   Query   SELECT   *   FROM   `artist`




http://ronaldbradford.com/blog/optimizing-sql-performance-the-art-of-elimination-2010-07-08/


                The most common MySQL scalability mistakes, and how to avoid them.
                                                                  @RonaldBradford #surgecon
EXAMPLE
  SELECT pages_id, pages_livestats_code, pages_title,
         pages_parent, pages_exhibid, pages_theme,
         pages_accession_num
  FROM pages WHERE pages_id = 0




       5 minutes
       6000 executions
       0 is out of bounds
http://ronaldbradford.com/blog/optimizing-sql-performance-the-art-of-elimination-2010-07-08/


               The most common MySQL scalability mistakes, and how to avoid them.
                                                                 @RonaldBradford #surgecon
HOW

Capture & Analyze
DML is easy
SELECT is harder
http://www.slideshare.net/ronaldbradford/capturing-analyzing-and-optimizing-mysql




         The most common MySQL scalability mistakes, and how to avoid them.
                                                           @RonaldBradford #surgecon
HOW
    MySQL Binary (Redo) Log
         mysqlbinlog
           mk-query-digest
           One Liner
http://ronaldbradford.com/blog/mysql-dml-stats-per-table-2009-09-09/



           The most common MySQL scalability mistakes, and how to avoid them.
                                                             @RonaldBradford #surgecon
HOW
Process List
General Log
tcpdump
Application



    The most common MySQL scalability mistakes, and how to avoid them.
                                                      @RonaldBradford #surgecon
HOW
Capturing, Analyzing and Optimizing
your SQL
  http://www.slideshare.net/ronaldbradford/capturing-analyzing-and-
  optimizing-mysql




          The most common MySQL scalability mistakes, and how to avoid them.
                                                            @RonaldBradford #surgecon
EXPERT TIP
/* Comment your queries */
The more products you have, the
more developers you have, the
more time you spend in code
identification before you can even
determine a resolution

    The most common MySQL scalability mistakes, and how to avoid them.
                                                      @RonaldBradford #surgecon
3
The most common MySQL scalability mistakes, and how to avoid them.
                                                  @RonaldBradford #surgecon
PROBLEM

The database is slow.
My webpage takes five
seconds to load.



   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
SOLUTION

Evaluate the time taken in
the database and all
stages in between



   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
EXAMPLE
Client example showed a webpage
taking 5 seconds to load. The html
component was taking only 400 ms.
Any MySQL performance
improvement will only tune 8% of
the total time.


    The most common MySQL scalability mistakes, and how to avoid them.
                                                      @RonaldBradford #surgecon
WHY

Performance is important
to end user
Performance is perception



   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
HOW
Firebug - http://getfirebug.com/
Httpwatch - http://httpwatch.com/
Page speed - http://code.google.com/speed/page-speed/
YSlow - http://developer.yahoo.com/yslow/
wget/curl
Application code instrumentation
      The most common MySQL scalability mistakes, and how to avoid them.
                                                        @RonaldBradford #surgecon
EXPERT TIP
http://www.stevesouders.com/
http://developer.yahoo.com/
performance/rules.html




    The most common MySQL scalability mistakes, and how to avoid them.
                                                      @RonaldBradford #surgecon
2
The most common MySQL scalability mistakes, and how to avoid them.
                                                  @RonaldBradford #surgecon
PROBLEM

I want to add new H/W.
How do I change my
application to support this?



   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
SOLUTION

Develop a seamless
integration that requires no
code changes, no downtime
and very little additional
physical resources.

   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
HOW
Integrated monitoring and
instrumentation
  Deployed from Day 1




    The most common MySQL scalability mistakes, and how to avoid them.
                                                      @RonaldBradford #surgecon
HOW
Seamless automated server
deployment
  Version Control
  Build & Release
  Runtime config management
  Automated discovery
   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
HOW
API
 One code path for business
 functionality
 Implied business documentation
 Enforced data exchange standard
 Testability
      The most common MySQL scalability mistakes, and how to avoid them.
                                                        @RonaldBradford #surgecon
HOW
Different levels of data availability
   Read & Write
   Read Only
   No Access
   Cached

    The most common MySQL scalability mistakes, and how to avoid them.
                                                      @RonaldBradford #surgecon
HOW
Different principles for scalability
   Read Scalability
   Write Scalability
   Caching



    The most common MySQL scalability mistakes, and how to avoid them.
                                                      @RonaldBradford #surgecon
1
The most common MySQL scalability mistakes, and how to avoid them.
                                                  @RonaldBradford #surgecon
PROBLEM

My website is slow?




   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
SOLUTION

Seek professional advice.
Hire for example Ronald
Bradford.



   The most common MySQL scalability mistakes, and how to avoid them.
                                                     @RonaldBradford #surgecon
WHY
20+ years of system architecture,
database design and performance
tuning.
Employment as Senior Consultant
with both Oracle Corporation
(96-99) and MySQL Inc (06-08)

  The most common MySQL scalability mistakes, and how to avoid them.
                                                    @RonaldBradford #surgecon
HOW
http://ronaldbradford.com
me@ronaldbradford.com
Take my business card



 The most common MySQL scalability mistakes, and how to avoid them.
                                                   @RonaldBradford #surgecon
R
The most common MySQL scalability mistakes, and how to avoid them.
                                                  @RonaldBradford #surgecon
RECAP
Monitoring. Before, during and after NOW.
You may not be able to predict the future
but you can preempt the future.
Choose the best product and features for
you needs.
The best SQL statement is the one
you never have to execute.

     The most common MySQL scalability mistakes, and how to avoid them.
                                                       @RonaldBradford #surgecon
RECAP
3 levels of real time data access.
   Read/Write, Read and no access
3 aspects of scalability.
   Read, Write and Caching
Operate below 90% capacity. That 10% is
your insurance.



     The most common MySQL scalability mistakes, and how to avoid them.
                                                       @RonaldBradford #surgecon
Not covered
My web pages are timing out
My website takes a long time to aggregate
results




     The most common MySQL scalability mistakes, and how to avoid them.
                                                       @RonaldBradford #surgecon
REFERENCE
Successful MySQL Scalability
1. Integrated monitoring & instrumentation
2. Seamless automated server deployment
3. Disaster is inevitable
4. Application Programming Interface
5. Support different levels of data availability
6. Support different scalability principles

      The most common MySQL scalability mistakes, and how to avoid them.
                                                        @RonaldBradford #surgecon
CONTACT
http://ronaldbradford.com
me@ronaldbradford.com




 The most common MySQL scalability mistakes, and how to avoid them.
                                                   @RonaldBradford #surgecon

Más contenido relacionado

Más de Ronald Bradford

MySQL Scalability Mistakes - OTN
MySQL Scalability Mistakes - OTNMySQL Scalability Mistakes - OTN
MySQL Scalability Mistakes - OTNRonald Bradford
 
My SQL Idiosyncrasies That Bite OTN
My SQL Idiosyncrasies That Bite OTNMy SQL Idiosyncrasies That Bite OTN
My SQL Idiosyncrasies That Bite OTNRonald Bradford
 
MySQL Best Practices - OTN LAD Tour
MySQL Best Practices - OTN LAD TourMySQL Best Practices - OTN LAD Tour
MySQL Best Practices - OTN LAD TourRonald Bradford
 
MySQL Idiosyncrasies That Bite SF
MySQL Idiosyncrasies That Bite SFMySQL Idiosyncrasies That Bite SF
MySQL Idiosyncrasies That Bite SFRonald Bradford
 
Successful MySQL Scalability
Successful MySQL ScalabilitySuccessful MySQL Scalability
Successful MySQL ScalabilityRonald Bradford
 
MySQL Idiosyncrasies That Bite 2010.07
MySQL Idiosyncrasies That Bite 2010.07MySQL Idiosyncrasies That Bite 2010.07
MySQL Idiosyncrasies That Bite 2010.07Ronald Bradford
 
Capturing, Analyzing and Optimizing MySQL
Capturing, Analyzing and Optimizing MySQLCapturing, Analyzing and Optimizing MySQL
Capturing, Analyzing and Optimizing MySQLRonald Bradford
 
MySQL Idiosyncrasies That Bite
MySQL Idiosyncrasies That BiteMySQL Idiosyncrasies That Bite
MySQL Idiosyncrasies That BiteRonald Bradford
 
10x Performance Improvements
10x Performance Improvements10x Performance Improvements
10x Performance ImprovementsRonald Bradford
 
LIFTOFF - MySQLCamp for the Oracle DBA
LIFTOFF - MySQLCamp for the Oracle DBALIFTOFF - MySQLCamp for the Oracle DBA
LIFTOFF - MySQLCamp for the Oracle DBARonald Bradford
 
IGNITION - MySQLCamp for the Oracle DBA
IGNITION - MySQLCamp for the Oracle DBAIGNITION - MySQLCamp for the Oracle DBA
IGNITION - MySQLCamp for the Oracle DBARonald Bradford
 
10x Performance Improvements - A Case Study
10x Performance Improvements - A Case Study10x Performance Improvements - A Case Study
10x Performance Improvements - A Case StudyRonald Bradford
 
Dolphins Now And Beyond - FOSDEM 2010
Dolphins Now And Beyond - FOSDEM 2010Dolphins Now And Beyond - FOSDEM 2010
Dolphins Now And Beyond - FOSDEM 2010Ronald Bradford
 
Drizzle - Status, Principles and Ecosystem
Drizzle - Status, Principles and EcosystemDrizzle - Status, Principles and Ecosystem
Drizzle - Status, Principles and EcosystemRonald Bradford
 
MySQL for the Oracle DBA - Object Management
MySQL for the Oracle DBA - Object ManagementMySQL for the Oracle DBA - Object Management
MySQL for the Oracle DBA - Object ManagementRonald Bradford
 
Know Your Competitor - Oracle 10g Express Edition
Know Your Competitor - Oracle 10g Express EditionKnow Your Competitor - Oracle 10g Express Edition
Know Your Competitor - Oracle 10g Express EditionRonald Bradford
 
MySQL For Oracle DBA's and Developers
MySQL For Oracle DBA's and DevelopersMySQL For Oracle DBA's and Developers
MySQL For Oracle DBA's and DevelopersRonald Bradford
 
MySQL For Oracle Developers
MySQL For Oracle DevelopersMySQL For Oracle Developers
MySQL For Oracle DevelopersRonald Bradford
 
The Ideal Performance Architecture
The Ideal Performance ArchitectureThe Ideal Performance Architecture
The Ideal Performance ArchitectureRonald Bradford
 

Más de Ronald Bradford (20)

MySQL Scalability Mistakes - OTN
MySQL Scalability Mistakes - OTNMySQL Scalability Mistakes - OTN
MySQL Scalability Mistakes - OTN
 
My SQL Idiosyncrasies That Bite OTN
My SQL Idiosyncrasies That Bite OTNMy SQL Idiosyncrasies That Bite OTN
My SQL Idiosyncrasies That Bite OTN
 
MySQL Best Practices - OTN LAD Tour
MySQL Best Practices - OTN LAD TourMySQL Best Practices - OTN LAD Tour
MySQL Best Practices - OTN LAD Tour
 
MySQL Idiosyncrasies That Bite SF
MySQL Idiosyncrasies That Bite SFMySQL Idiosyncrasies That Bite SF
MySQL Idiosyncrasies That Bite SF
 
Successful MySQL Scalability
Successful MySQL ScalabilitySuccessful MySQL Scalability
Successful MySQL Scalability
 
MySQL Idiosyncrasies That Bite 2010.07
MySQL Idiosyncrasies That Bite 2010.07MySQL Idiosyncrasies That Bite 2010.07
MySQL Idiosyncrasies That Bite 2010.07
 
Capturing, Analyzing and Optimizing MySQL
Capturing, Analyzing and Optimizing MySQLCapturing, Analyzing and Optimizing MySQL
Capturing, Analyzing and Optimizing MySQL
 
MySQL Idiosyncrasies That Bite
MySQL Idiosyncrasies That BiteMySQL Idiosyncrasies That Bite
MySQL Idiosyncrasies That Bite
 
10x Performance Improvements
10x Performance Improvements10x Performance Improvements
10x Performance Improvements
 
LIFTOFF - MySQLCamp for the Oracle DBA
LIFTOFF - MySQLCamp for the Oracle DBALIFTOFF - MySQLCamp for the Oracle DBA
LIFTOFF - MySQLCamp for the Oracle DBA
 
IGNITION - MySQLCamp for the Oracle DBA
IGNITION - MySQLCamp for the Oracle DBAIGNITION - MySQLCamp for the Oracle DBA
IGNITION - MySQLCamp for the Oracle DBA
 
10x Performance Improvements - A Case Study
10x Performance Improvements - A Case Study10x Performance Improvements - A Case Study
10x Performance Improvements - A Case Study
 
Dolphins Now And Beyond - FOSDEM 2010
Dolphins Now And Beyond - FOSDEM 2010Dolphins Now And Beyond - FOSDEM 2010
Dolphins Now And Beyond - FOSDEM 2010
 
Drizzle - Status, Principles and Ecosystem
Drizzle - Status, Principles and EcosystemDrizzle - Status, Principles and Ecosystem
Drizzle - Status, Principles and Ecosystem
 
SQL v No SQL
SQL v No SQLSQL v No SQL
SQL v No SQL
 
MySQL for the Oracle DBA - Object Management
MySQL for the Oracle DBA - Object ManagementMySQL for the Oracle DBA - Object Management
MySQL for the Oracle DBA - Object Management
 
Know Your Competitor - Oracle 10g Express Edition
Know Your Competitor - Oracle 10g Express EditionKnow Your Competitor - Oracle 10g Express Edition
Know Your Competitor - Oracle 10g Express Edition
 
MySQL For Oracle DBA's and Developers
MySQL For Oracle DBA's and DevelopersMySQL For Oracle DBA's and Developers
MySQL For Oracle DBA's and Developers
 
MySQL For Oracle Developers
MySQL For Oracle DevelopersMySQL For Oracle Developers
MySQL For Oracle Developers
 
The Ideal Performance Architecture
The Ideal Performance ArchitectureThe Ideal Performance Architecture
The Ideal Performance Architecture
 

Último

Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
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 2024The Digital Insurer
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
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 Servicegiselly40
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
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...Neo4j
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
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 slidevu2urc
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 

Último (20)

Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
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...
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 

Common MySQL Scalability Mistakes and how to avoid them.

  • 1. The most common MySQL scalability mistakes, and how to avoid them. 2010.08 Ronald Bradford www.RonaldBradford.com The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 2. 9 The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 3. PROBLEM My website seems to freeze or responds randomly? The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 4. CAUSE The default MyISAM storage engine uses exclusive table locks for DML. The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 5. SOLUTION Optimize blocking query performance Use a transactional engine with MVCC and row based locking to address the LOCKING issue The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 6. EXAMPLE Crazy end user report that selects all customer, order, order lines and order history data and performs poor joins. This takes shared read locks blocking future write locks then future reads. The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 7. WHY MySQL is unique in that it offers different mechanisms for storing and retrieving data, each with strengths and weaknesses. The DEFAULT is not always the best. The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 8. HOW MySQL PROCESSLIST Blocked have State = Locked Blocker - Same table, older Time mysql> SHOW PROCESSLIST; +----+------+-----------+-------+---------+------+------------+--------------- | Id | User | Host | db | Command | Time | State | Info +----+------+-----------+-------+---------+------+------------+--------------- | 13 | root | localhost | odtug | Query | 144 | User sleep | UPDATE test1 ... | 14 | root | localhost | odtug | Query | 116 | Locked | select * from test1 | 15 | root | localhost | odtug | Query | 89 | Locked | select * from test1 The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 9. HOW Optimize Blocker Indexes Limit query Summary table Change storage engine The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 10. 8 The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 11. PROBLEM Why is my database so large? The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 12. SOLUTION Don’t store large static objects in the database The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 13. EXAMPLE 80% of data is email content/ attachments 60% of data is PDF documents 30% of data is uncompressed large XML objects The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 14. WHY Maximize memory usage for important data Reduce database recovery time The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 15. HOW Compress large text data 90% saving on XML data Store static data in files Avoids DB handling overhead The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 16. HOW Table Size per schema # Schema Table Usage SELECT table_schema,table_name,engine,row_format, table_rows, avg_row_length, (data_length+index_length)/1024/1024 as total_mb, (data_length)/1024/1024 as data_mb, (index_length)/1024/1024 as index_mb, CURDATE() AS today FROM information_schema.tables WHERE table_schema = DATABASE() ORDER BY 7 DESC; The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 17. 7 The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 18. PROBLEM I can't access my website? The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 19. TRUE STORY The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 20. TRUE STORY Question: The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 21. TRUE STORY Question: How do you know when your server is down or not accessible? The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 22. TRUE STORY Question: How do you know when your server is down or not accessible? Answer: The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 23. TRUE STORY Question: How do you know when your server is down or not accessible? Answer: The users will let us know. The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 24. SOLUTION Monitoring Alerting Dashboard Status Site The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 25. HOW Monitoring/Alerting Graphical Historical Necessary Generally missing/incomplete Useless for real-time analysis The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 26. HOW Dashboard The state of NOW Sampling at 1s/3s/5s e.g. 0.1% of throughput The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 27. HOW Instrumentation Important to business viability e.g. orders per minute page load time Seamless implementation i.e. no code changes to view real-time extensible The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 28. HOW Have a status website allow for comments (e.g. blog) Have a public dashboard website Host them somewhere else! The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 29. 6 The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 30. PROBLEM My replication slave can't keep up? The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 31. SOLUTION Know the weakest link(s) of MySQL replication and don't exceed that, or cheat. The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 32. WHY If replication can't catchup, slaves are useless. Backup & recovery may also suffer. The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 33. HOW Master DML Statement Write Data/Redo Log Write Binary Log Return OK to client The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 34. HOW Slave Detect master log change Retrieve binary log entry Write relay log (IO_THREAD) Read relay log Apply DML (SQL_THREAD) Write Data/redo log The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 35. HOW Clever workarounds Restrict queries executed --ignore Different storage engines Different index structures The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 36. EXPERT TIP Cheating RAID 0 (large number of slaves) Pre fetch thread The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 37. 5 The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 38. PROBLEM My server has crashed with a hard drive failure The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 39. TRUE STORY Question: Have you ever performed a database recovery? Answer: No, why? The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 40. TRUE STORY Consultant: Do you know that your daily backups only recover the data up to that time, e.g. 1am. You know you have lost all your sales and changes since then. Customer: No, I didn’t know that. The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 41. SOLUTION Have a DR Plan Documented Tested Timed Verified - End to End The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 42. HOW Do you pass the MySQL backup/ recovery quiz? http://rb42.com/mysql-backup-quiz The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 43. QUIZ 1. Do you have MySQL backups in place? 2. Do you backup ALL your MySQL data? 3. Do you have consistent MySQL backups? 4. Do you have backups that include both static snapshot and point in time transactions? 5. Do you review your backup logs EVERY SINGLE day or have tested backup monitoring in place? 6. Do you perform a test recovery of your static backup? 7. Do you perform a test recovery to point in time? 8. Do you time your backup and recovery process and review over time? 9. Do you have off-site copies of your backups? 10. Do you backup your primary binary logs? http://rb42.com/mysql-backup-quiz The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 44. 4 The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 45. PROBLEM Why is my database executing 1,200 qps for 50 users? The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 46. SOLUTION Determine what queries are running and why they are running? The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 47. CAUSE Excessive SQL statements Duplicate Redundant Cachable Row at a time (RAT) The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 48. WHY Reducing SQL load both improves performance now and provides greater capacity as you scale The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 49. EXAMPLE SELECT option_name, option_value FROM wp_options WHERE autoload = 'yes' SELECT option_value FROM wp_options WHERE option_name = 'aiosp_title_format' LIMIT 1 SELECT option_value FROM wp_options WHERE option_name = 'ec3_show_only_even' LIMIT 1 SELECT option_value FROM wp_options WHERE option_name = 'ec3_num_months' LIMIT 1 SELECT option_value FROM wp_options WHERE option_name = 'ec3_day_length' LIMIT 1 SELECT option_value FROM wp_options WHERE option_name = 'ec3_hide_event_box' LIMIT 1 SELECT option_value FROM wp_options WHERE option_name = 'ec3_advanced' LIMIT 1 SELECT option_value FROM wp_options WHERE option_name = 'ec3_navigation' LIMIT 1 SELECT option_value FROM wp_options WHERE option_name = 'ec3_disable_popups' LIMIT 1 SELECT option_value FROM wp_options WHERE option_name = 'sidebars_widgets' LIMIT 1 http://ronaldbradford.com/blog/we-need-more-cats-2009-08-22/ The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 50. EXAMPLE SELECT * FROM activities_theme WHERE theme_parent_id=0 SELECT * FROM activities_theme WHERE theme_parent_id=1 SELECT * FROM activities_theme WHERE theme_parent_id=2 SELECT * FROM activities_theme WHERE theme_parent_id=11 SELECT * FROM activities_theme WHERE theme_parent_id=16 SELECT * FROM activities_theme WHERE theme_parent_id in (0,1,2,11,16) http://ronaldbradford.com/blog/optimizing-sql-performance-the-art-of-elimination-2010-07-08/ The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 51. EXAMPLE 5 Query SELECT * FROM `artist` 5 Query SELECT * FROM `artist` 5 Query SELECT * FROM `artist` 5 Query SELECT * FROM `artist` 5 Query SELECT * FROM `artist` 5 Query SELECT * FROM `artist` WHERE (ArtistID = 196 ) 5 Query SELECT * FROM `artist` WHERE (ArtistID = 2188 ) 5 Query SELECT * FROM `artist` 5 Query SELECT * FROM `artist` 5 Query SELECT * FROM `artist` http://ronaldbradford.com/blog/optimizing-sql-performance-the-art-of-elimination-2010-07-08/ The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 52. EXAMPLE SELECT pages_id, pages_livestats_code, pages_title, pages_parent, pages_exhibid, pages_theme, pages_accession_num FROM pages WHERE pages_id = 0 5 minutes 6000 executions 0 is out of bounds http://ronaldbradford.com/blog/optimizing-sql-performance-the-art-of-elimination-2010-07-08/ The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 53. HOW Capture & Analyze DML is easy SELECT is harder http://www.slideshare.net/ronaldbradford/capturing-analyzing-and-optimizing-mysql The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 54. HOW MySQL Binary (Redo) Log mysqlbinlog mk-query-digest One Liner http://ronaldbradford.com/blog/mysql-dml-stats-per-table-2009-09-09/ The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 55. HOW Process List General Log tcpdump Application The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 56. HOW Capturing, Analyzing and Optimizing your SQL http://www.slideshare.net/ronaldbradford/capturing-analyzing-and- optimizing-mysql The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 57. EXPERT TIP /* Comment your queries */ The more products you have, the more developers you have, the more time you spend in code identification before you can even determine a resolution The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 58. 3 The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 59. PROBLEM The database is slow. My webpage takes five seconds to load. The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 60. SOLUTION Evaluate the time taken in the database and all stages in between The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 61. EXAMPLE Client example showed a webpage taking 5 seconds to load. The html component was taking only 400 ms. Any MySQL performance improvement will only tune 8% of the total time. The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 62. WHY Performance is important to end user Performance is perception The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 63. HOW Firebug - http://getfirebug.com/ Httpwatch - http://httpwatch.com/ Page speed - http://code.google.com/speed/page-speed/ YSlow - http://developer.yahoo.com/yslow/ wget/curl Application code instrumentation The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 64. EXPERT TIP http://www.stevesouders.com/ http://developer.yahoo.com/ performance/rules.html The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 65. 2 The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 66. PROBLEM I want to add new H/W. How do I change my application to support this? The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 67. SOLUTION Develop a seamless integration that requires no code changes, no downtime and very little additional physical resources. The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 68. HOW Integrated monitoring and instrumentation Deployed from Day 1 The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 69. HOW Seamless automated server deployment Version Control Build & Release Runtime config management Automated discovery The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 70. HOW API One code path for business functionality Implied business documentation Enforced data exchange standard Testability The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 71. HOW Different levels of data availability Read & Write Read Only No Access Cached The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 72. HOW Different principles for scalability Read Scalability Write Scalability Caching The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 73. 1 The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 74. PROBLEM My website is slow? The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 75. SOLUTION Seek professional advice. Hire for example Ronald Bradford. The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 76. WHY 20+ years of system architecture, database design and performance tuning. Employment as Senior Consultant with both Oracle Corporation (96-99) and MySQL Inc (06-08) The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 77. HOW http://ronaldbradford.com me@ronaldbradford.com Take my business card The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 78. R The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 79. RECAP Monitoring. Before, during and after NOW. You may not be able to predict the future but you can preempt the future. Choose the best product and features for you needs. The best SQL statement is the one you never have to execute. The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 80. RECAP 3 levels of real time data access. Read/Write, Read and no access 3 aspects of scalability. Read, Write and Caching Operate below 90% capacity. That 10% is your insurance. The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 81. Not covered My web pages are timing out My website takes a long time to aggregate results The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 82. REFERENCE Successful MySQL Scalability 1. Integrated monitoring & instrumentation 2. Seamless automated server deployment 3. Disaster is inevitable 4. Application Programming Interface 5. Support different levels of data availability 6. Support different scalability principles The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon
  • 83. CONTACT http://ronaldbradford.com me@ronaldbradford.com The most common MySQL scalability mistakes, and how to avoid them. @RonaldBradford #surgecon