Knowledge Bank

From how to best plan and execute a server migration through to utilising MySQL replication, this section is full of white papers and best practice guidelines, produced by the experts here at ForLinux to help you get the most from your Linux server.

MySQL Server hosting


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

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:
for info about MySQL's Enterprise Monitoring and Advisory Service

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.

The binary update log is NOT enabled.
You will not be able to do point in time recovery

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

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.

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

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 is supported but not enabled
Perhaps you should set the query_cache_size

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

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.

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

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

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.

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

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 dedicated server on or complete the contact form on the right.

Get In Touch...