MySQL Server Hosting

Tuning MySQL Server in a hosting environment can be a can of worms. This script -

http://www.day32.com/MySQL/tuning-primer.sh

will help diagnose possible configuration issues.

This script takes information from “SHOW STATUS LIKE…” and “SHOW VARIABLES LIKE…”
to produce sane recommendations for tuning server variables.
It is compatible with all versions of MySQL 3.23 and higher (including 5.1).

Currently it handles recommendations for the following:

  • Slow Query Log
  • Max Connections
  • Worker Threads
  • Key Buffer
  • Query Cache
  • Sort Buffer
  • Joins
  • Temp Tables
  • Table (Open & Definition) Cache
  • Table Locking
  • Table Scans (read_buffer)
  • Innodb StatusRecent Changes
  • Correct awk display error which formats integers > 4294967296 in scientific notation.
    - Was manfest in MEMORY USAGE section where total system RAM > 4GB.
  • Fixed rounding error where mysql will lose 4K from the join_buffer_size value.
    - Other values may have the same issue but are not yet reported
  • Added support for FreeBSD and MacOS (thanks Sam and Geert)
  • Added support for Solaris
  • Changed how system memory is derived on Linux.
    - Use /proc/meminfo vs free -b and avoid inclusion of swap space.
  • Include note warning of instability when key_buffer_size > 4GB in versions 5.0.51 and lower
  • Example Output -

    MySQL Version 4.1.22-standard i686

    Uptime = 103 days 22 hrs 14 min 37 sec
    Avg. qps = 460
    Total Questions = 4131113780
    Threads Connected = 5

    Server has been running for over 48hrs.
    It should be safe to follow these recommendations

    To find out more information on how each of these
    runtime variables effects performance visit:

    http://dev.mysql.com/doc/refman/4.1/en/server-system-variables.html

    Visit http://www.mysql.com/products/enterprise/advisors.html
    for info about MySQL’s Enterprise Monitoring and Advisory Service

    SLOW QUERIES
    The slow query log is NOT enabled.
    Current long_query_time = 10 sec.
    You have 740 out of 4131113798 that take longer than 10 sec. to complete
    Your long_query_time may be too high, I typically set this under 5 sec.

    BINARY UPDATE LOG
    The binary update log is NOT enabled.
    You will not be able to do point in time recovery
    See http://dev.mysql.com/doc/refman/4.1/en/point-in-time-recovery.html

    WORKER THREADS
    Current thread_cache_size = 0
    Current threads_cached = 0
    Current threads_per_sec = 1
    Historic threads_per_sec = 0
    Your thread_cache_size is fine

    MAX CONNECTIONS
    Current max_connections = 500
    Current threads_connected = 3
    Historic max_used_connections = 153
    The number of used connections is 30% of the configured maximum.
    Your max_connections variable seems to be fine.

    MEMORY USAGE
    Max Memory Ever Allocated : 429 M
    Configured Max Per-thread Buffers : 1 G
    Configured Max Global Buffers : 17 M
    Configured Max Memory Limit : 1 G
    Physical Memory : 3.95 G
    Max memory limit seem to be within acceptable norms

    KEY BUFFER
    Current MyISAM index space = 510 M
    Current key_buffer_size = 7 M
    Key cache miss rate is 1 : 10620
    Key buffer fill ratio = 51.00 %
    Your key_buffer_size seems to be too high.
    Perhaps you can use these resources elsewhere

    QUERY CACHE
    Query cache is supported but not enabled
    Perhaps you should set the query_cache_size

    SORT OPERATIONS
    Current sort_buffer_size = 2 M
    Current read_rnd_buffer_size = 256 K
    Sort buffer seems to be fine

    JOINS
    Current join_buffer_size = 132.00 K
    You have had 10658991 queries where a join could not use an index properly
    You should enable “log-queries-not-using-indexes”
    Then look for non indexed joins in the slow query log.
    If you are unable to optimize your queries you may want to increase your
    join_buffer_size to accommodate larger joins in one pass.

    Note! This script will still suggest raising the join_buffer_size when
    ANY joins not using indexes are found.

    OPEN FILES LIMIT
    Current open_files_limit = 2500 files
    The open_files_limit should typically be set to at least 2x-3x
    that of table_cache if you have heavy MyISAM usage.
    Your open_files_limit value seems to be fine

    TABLE CACHE
    Current table_cache value = 64 tables
    You have a total of 470 tables
    You have 64 open tables.
    Current table_cache hit rate is 0%, while 100% of your table cache is in use
    You should probably increase your table_cache

    TEMP TABLES
    Current max_heap_table_size = 16 M
    Current tmp_table_size = 32 M
    Of 12574936 temp tables, 98% were created on disk
    Effective in-memory tmp_table_size is limited to max_heap_table_size.
    Perhaps you should increase your tmp_table_size and/or max_heap_table_size
    to reduce the number of disk-based temporary tables
    Note! BLOB and TEXT columns are not allow in memory tables.
    If you are using these columns raising these values might not impact your
    ratio of on disk temp tables.

    TABLE SCANS
    Current read_buffer_size = 128 K
    Current table scan ratio = 1 : 1
    read_buffer_size seems to be fine

    TABLE LOCKING
    Current Lock Wait ratio = 1 : 118167
    Your table locking seems to be fine

    If your website depends on MySQL then don’t leave performance tuning to chance, contact ForLinux now for a tuned MySQL hosted server on 01636 881200 or complete the contact form on the right.

    « | Home | »

    • Call us

      Switchboard:
      Tel: 0845 4210444

      Sales:
      Tel: 0845 4210440
    • Get in touch

      Your Name (required)

      Your Email (required)

      I am interested in
       Hosting Support Training

      Your Message

    • Join our mailing list

      To receive our latest Whitepapers free of charge and direct to your inbox on a fortnightly basis, sign up to our mailing list.
    • Training offer

    Xen solution meets e-commerce demand

    “A lot of hosting companies talk about 99.999% SLA, this means nothing if their support fails to deliver but with ForLinux’s support you know you’re in good hands. I’ve just checked one of our older servers that’s due to be replaced this year, it’s uptime is 902 Days! Needles to say ForLinux will be handling the upgrade.” Ashley Peake, Technical Director, Rapid Web Ltd.

    The proactive monitoring service is crucial

    “The proactive monitoring service that ForLinux provide is crucial to our business. When a problem occurs, the ForLinux team ring us with a potential solution, which they are ready to work on straight away”. Sam Phillips, Technical Director, Setfire Media.

    “The level of support ForLinux offer is very high”

    “The ForLinux team are very knowledgeable and there is always someone who can deal with the problems and errors we incur. I wouldn’t dream of hosting my dedicated server alone, without that extra support”. Chris Chaplow, Managing Director, Andalucia.com

    “ForLinux are a world apart”

    “Compared to other hosting and support companies we have dealt with, ForLinux are a world apart. In our experience the level of service provided by ForLinux is very high”. Alan Taylor, Managing Director, Blue Chip Vacations

    Understanding “Support”

    “Thanks for your help. If only all the companies we deal with understood what “support” means as well as you do.” – Mike Busuttili, Webmaster, Eaton Publications.

    “Five year partnership speaks for itself”

    “They’re very good at being proactive rather than reactive. The five years of partnership pretty much speaks for itself. And it has been improving all the time, so satisfaction levels are still high. The price is surprisingly good as well for the kind of industry they’re in, so that’s another plus point. ” Danny Ramdenee, Head of IT, Insurancewide

    “Application uptime is above 99.98%”

    “The ForLinux organisation appears the perfect size to perform its function well, it is large enough not be reliant on one or two people but small enough to ensure that, as the customer, you know the technical staff and they know you. I have great confidence in the technical competence of the ForLinux team.” – John Latham, Managing Director, Cognovi.

    “Customer service is phenomenal”

    “I respect the service that the company provide & it is nice to finally find a hosting company that operates in the same way as we do, in terms of ethos. It sounds like a cliché but the Customer service really is phenomenal!” – Stafford Sumner, Managing Director, Jarrang.

    Deploying virtual servers on Amazon

    Creating a Linux Server in the Cloud
    Technical Director of ForLinux Ltd, Steve Nice, recently wrote an article for .Net Magazine, which demonstrates how to set up an Amazon Web Services EC2 Instance, running Linux and Apache.
    The feature contains a step by step tutorial guide to installing and deploying virtual servers on the Amazon EC2 network [...]

    Scaling Apache, MySQL & PHP

    Overview of Scaling your Apache PHP MySQL Hosted website
    This is a short post on the basic principles of scaling your Apache PHP MySQL based hosted website.
    Scaling your website isn’t as simple as introducing a new web server.  It is easy to upgrade the hardware however, there are the issues associated with migrating the website to [...]

    Amazon Cloud EC2 Pricing Summary

    Amazon Cloud EC2 Pricing Summary
    Amazon Web Services (aka EC2, Amazon Cloud Computing, AWS) provide you with the ability to create virtual servers and only pay for them while they are in use. The virtual servers (known as Instances) can be various sizes ,in terms of CPU, RAM and temporary disk space. Disk space is temporary, [...]

    Tomcat Apache

    ForLinux Dedicated servers are supported by Linux Professionals who will be able to assist you in configuration and installation of Tomcat.  Complete the contact form on the right to discuss the best options for your hosting.