Hello there, I need some advice on optimizing MySQL settings, I run two Wordpress blogs, one of them with high traffic and the other one not so high but a mobile app connects to this blog to fetch data and it has even more traffic than the first blog, around 1000 people conected to the server in total most of the time.
I have problems of CPU, and a lot of ram free, both blogs use W3 Total Cache with XCache.
Server Info:
mysqltuner.pl:
tuning-primer.sh:
my.cnf:
Thanks
.
I have problems of CPU, and a lot of ram free, both blogs use W3 Total Cache with XCache.
Server Info:
Code:
MySQL: 5.5.32-cll
RAM: 8GB
Total processors: 4
Vendor: AuthenticAMD
Name: AMD Athlon(tm) II X4 605e Processor
Speed: 2295.351 MHz
Cache: 512 KB
Code:
>> MySQLTuner 1.2.0 - Major Hayden <[email protected]>
>> Bug reports, feature requests, and downloads at http://mysqltuner.com/
>> Run with '--help' for additional options and output filtering
-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.5.32-cll
[OK] Operating on 64-bit architecture
-------- Storage Engine Statistics -------------------------------------------
[--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 1M (Tables: 69)
[--] Data in InnoDB tables: 17M (Tables: 59)
[--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 17)
[!!] Total fragmented tables: 8
-------- Security Recommendations -------------------------------------------
[OK] All database users have passwords assigned
-------- Performance Metrics -------------------------------------------------
[--] Up for: 1d 3h 42m 9s (15M q [156.645 qps], 697K conn, TX: 24B, RX: 1B)
[--] Reads / Writes: 99% / 1%
[--] Total buffers: 4.5G global + 2.9M per thread (150 max threads)
[OK] Maximum possible memory usage: 4.9G (65% of installed RAM)
[OK] Slow queries: 0% (105K/15M)
[OK] Highest usage of available connections: 33% (50/150)
[OK] Key buffer size / total MyISAM indexes: 16.0M/400.0K
[OK] Key buffer hit rate: 100.0% (674K cached / 272 reads)
[OK] Query cache efficiency: 94.0% (12M cached / 12M selects)
[!!] Query cache prunes per day: 16286
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 224K sorts)
[!!] Temporary tables created on disk: 31% (109K on disk / 352K total)
[OK] Thread cache hit rate: 99% (50 created / 697K connections)
[!!] Table cache hit rate: 0% (206 open / 58K opened)
[OK] Open file limit used: 0% (194/65K)
[OK] Table locks acquired immediately: 99% (979K immediate / 980K locks)
[OK] InnoDB data size / buffer pool: 17.3M/4.0G
-------- Recommendations -----------------------------------------------------
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
Increasing the query_cache size over 128M may reduce performance
When making adjustments, make tmp_table_size/max_heap_table_size equal
Reduce your SELECT DISTINCT queries without LIMIT clauses
Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
query_cache_size (> 256M) [see warning above]
tmp_table_size (> 192M)
max_heap_table_size (> 192M)
table_cache (> 2048)
Code:
-- MYSQL PERFORMANCE TUNING PRIMER --
- By: Matthew Montgomery -
MySQL Version 5.5.32-cll x86_64
Uptime = 1 days 3 hrs 43 min 12 sec
Avg. qps = 156
Total Questions = 15630157
Threads Connected = 3
Warning: Server has not been running for at least 48hrs.
It may not be safe to use these recommendations
To find out more information on how each of these
runtime variables effects performance visit:
http://dev.mysql.com/doc/refman/5.5/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 enabled.
Current long_query_time = 10.000000 sec.
You have 105081 out of 15630217 that take longer than 10.000000 sec. to complete
Your long_query_time seems to be fine
BINARY UPDATE LOG
The binary update log is enabled
WORKER THREADS
Current thread_cache_size = 50
Current threads_cached = 48
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine
MAX CONNECTIONS
Current max_connections = 150
Current threads_connected = 2
Historic max_used_connections = 50
The number of used connections is 33% of the configured maximum.
Your max_connections variable seems to be fine.
INNODB STATUS
Current InnoDB index space = 7 M
Current InnoDB data space = 17 M
Current InnoDB buffer pool free = 97 %
Current innodb_buffer_pool_size = 4.00 G
Depending on how much space your innodb indexes take up it may be safe
to increase this value to up to 2 / 3 of total system memory
MEMORY USAGE
Max Memory Ever Allocated : 4.42 G
Configured Max Per-thread Buffers : 435 M
Configured Max Global Buffers : 4.28 G
Configured Max Memory Limit : 4.70 G
Physical Memory : 7.43 G
Max memory limit seem to be within acceptable norms
KEY BUFFER
Current MyISAM index space = 409 K
Current key_buffer_size = 16 M
Key cache miss rate is 1 : 2481
Key buffer free ratio = 81 %
Your key_buffer_size seems to be fine
QUERY CACHE
Query cache is enabled
Current query_cache_size = 256 M
Current query_cache_used = 89 M
Current query_cache_limit = 4 M
Current Query cache Memory fill ratio = 35.07 %
Current query_cache_min_res_unit = 4 K
MySQL won't cache query results that are larger than query_cache_limit in 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 = 260.00 K
You have had 1 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 = 65535 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_open_cache = 2048 tables
Current table_definition_cache = 1024 tables
You have a total of 169 tables
You have 206 open tables.
The table_cache value seems to be fine
TEMP TABLES
Current max_heap_table_size = 192 M
Current tmp_table_size = 192 M
Of 243554 temp tables, 31% were created on disk
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 = 2323 : 1
read_buffer_size seems to be fine
TABLE LOCKING
Current Lock Wait ratio = 1 : 884
You may benefit from selective use of InnoDB.
If you have long running SELECT's against MyISAM tables and perform
frequent updates consider setting 'low_priority_updates=1'
If you have a high concurrency of inserts on Dynamic row-length tables
consider setting 'concurrent_insert=ALWAYS'.
Code:
[mysqld]
# GENERAL #
default-storage-engine = InnoDB
# MyISAM #
key-buffer-size = 16M
myisam-recover = FORCE,BACKUP
# SAFETY #
max-allowed-packet = 16M
max-connect-errors = 1000000
# DATA STORAGE #
datadir = /var/lib/mysql/
# BINARY LOGGING #
log-bin = /var/lib/mysql/mysql-bin
expire-logs-days = 14
sync-binlog = 1
# CACHES AND LIMITS #
tmp-table-size = 192M
max-heap-table-size = 192M
query-cache-type = 1
query-cache-size = 256M
query-cache-limit = 4M
max-connections = 150
thread-cache-size = 50
open-files-limit = 65535
table-definition-cache = 1024
table-open-cache = 2048
join_buffer_size = 256K
# INNODB #
innodb-flush-method = O_DIRECT
innodb-log-files-in-group = 2
innodb-log-file-size = 256M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table = 1
innodb-buffer-pool-size = 4G
# LOGGING #
log-error = /var/lib/mysql/mysql-error.log
log-queries-not-using-indexes = 1
slow-query-log = 1
slow-query-log-file = /var/lib/mysql/mysql-slow.log