Hello,
I have been having some load issues with my server due to the response time in the MySQL server (I suspect that it is due to that). The load hits to 15/20 at peak hours (like just about 2 hours) and is below 1 most of the time.

I have been tracking down the process on what is causing it and it seems it is the ajax chat on about 3 websites on the server. I would like to optimize the server in such a way that the ajax chat does not cause any issue to the server and slow down the other websites on the server.

Here are the latest reports:
MySQLTuner.PL
Code: 
-------- General Statistics  --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.1.45-log
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics  -------------------------------------------
[--] Status: -Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 413M (Tables: 4034)
[--] Data in InnoDB tables: 21M (Tables: 221)
[--] Data in MEMORY tables: 1020K (Tables: 1)
[!!] Total fragmented tables: 407

-------- Performance Metrics  -------------------------------------------------
[--] Up for: 4d 13h 57m 55s (20M q [51.597 qps], 1M conn, TX: 57B, RX:  5B)
[--] Reads / Writes: 68% / 32%
[--] Total buffers: 150.0M global + 7.6M per thread (100 max threads)
[OK] Maximum possible memory usage: 912.5M (45% of installed RAM)
[!!] Slow queries: 8% (1M/20M)
[OK] Highest usage of available connections: 32% (32/100)
[OK] Key buffer size / total MyISAM indexes: 64.0M/92.2M
[OK] Key buffer hit rate: 99.7% (123M cached / 363K reads)
[OK] Query cache efficiency: 59.7% (8M cached / 13M selects)
[!!] Query cache prunes per day: 69532
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 1M sorts)
[!!] Joins performed without indexes: 17009
[!!] Temporary tables created on disk: 28% (43K on disk / 150K total)
[OK] Thread cache hit rate: 99% (32 created / 1M connections)
[!!] Table cache hit rate: 2% (3K open / 142K opened)
[OK] Open file limit used: 8% (5K/65K)
[OK] Table locks acquired immediately: 99% (10M immediate / 10M locks)
[OK] InnoDB data size / buffer pool: 21.7M/32.0M

-------- Recommendations  -----------------------------------------------------
General recommendations:
    Run OPTIMIZE TABLE to defragment tables for better performance
    Adjust your join queries to always utilize indexes
    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 (> 20M)
    join_buffer_size (> 2.0M, or always use indexes with joins)
    tmp_table_size (> 32M)
    max_heap_table_size (> 32M)
    table_cache (> 3084)
Tuning-primer.sh
Code: 
MySQL Version 5.1.45-log x86_64

Uptime = 4 days 14 hrs 4 min 18 sec
Avg. qps = 51
Total Questions = 20461827
Threads Connected = 1

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/5.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 enabled.
Current long_query_time = 2.000000 sec.
You have 1675281 out of 20461856 that take longer than 2.000000 sec. to  complete
Your long_query_time seems to be fine

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/5.1/en/point-in-time-recovery.html

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

MAX CONNECTIONS
Current max_connections = 100
Current threads_connected = 1
Historic max_used_connections = 32
The number of used connections is 32% of the configured maximum.
Your max_connections variable seems to be fine.

INNODB STATUS
Current InnoDB index space = 6 M
Current InnoDB data space = 21 M
Current InnoDB buffer pool free = 24 %
Current innodb_buffer_pool_size = 32 M
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 : 362 M
Configured Max Per-thread Buffers : 762 M
Configured Max Global Buffers : 118 M
Configured Max Memory Limit : 880 M
Physical Memory : 1.95 G
Max memory limit seem to be within acceptable norms

KEY BUFFER
Current MyISAM index space = 92 M
Current key_buffer_size = 64 M
Key cache miss rate is 1 : 337
Key buffer free ratio = 81 %
Your key_buffer_size seems to be fine

QUERY CACHE
Query cache is enabled
Current query_cache_size = 20 M
Current query_cache_used = 13 M
Current query_cache_limit = 4 M
Current Query cache Memory fill ratio = 67.06 %
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 = 4 M
Current read_rnd_buffer_size = 512 K
Sort buffer seems to be fine

JOINS
Current join_buffer_size = 2.00 M
You have had 16944 queries where a join could not use an index properly
You have had 79 joins without keys that check for key usage after each  row
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 = 3084 tables
Current table_definition_cache = 12336 tables
You have a total of 4279 tables
You have 3084 open tables.
Current table_cache hit rate is 1%
, while 100% of your table cache is in use
You should probably increase your table_cache

TEMP TABLES
Current max_heap_table_size = 32 M
Current tmp_table_size = 32 M
Of 107143 temp tables, 28% 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 = 1 M
Current table scan ratio = 22 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 1 : 26658
Your table locking seems to be fine
Any help with it there?

I have the:
Code: 
log_slow_queries = /var/log/mysql/mysql-slow.log
enabled, although no queries show up in that file..


my.cnf
Code: 
[mysqld]
back_log = 75
max_connections = 100
key_buffer = 64M
myisam_sort_buffer_size = 64M
join_buffer_size = 2M
read_buffer_size = 1M
sort_buffer_size = 4M
table_cache = 6192
thread_cache_size = 384
wait_timeout = 106
connect_timeout = 10
tmp_table_size = 48M
max_heap_table_size = 48M
max_allowed_packet = 16M
max_connect_errors = 1000
read_rnd_buffer_size = 524288
bulk_insert_buffer_size = 8M
query_cache_limit = 4M
query_cache_size = 20M
query_cache_type = 1
query_prealloc_size = 65536
query_alloc_block_size = 131072
local-infile=0
table_cache = 3084
table_definition_cache = 12336
max_heap_table_size = 32M
tmp_table_size = 32M
thread_stack = 128K
innodb_buffer_pool_size = 32M
log_slow_queries = /var/log/mysql/mysql-slow.log
long_query_time = 2
log-queries-not-using-indexes
open_files_limit = 64M
concurrent_insert = 2
default-storage-engine = MyISAM

server-id = 1


[mysqld_safe]
nice = -5
open_files_limit = 8192

[mysqldump]
quick
max_allowed_packet = 16M

[myisamchk]
key_buffer = 64M
sort_buffer = 64M
read_buffer = 16M
write_buffer = 16M
I don't understand many of the bits as I have already set them right and it still says that they can be improved?

I have also optimized my Apache to a certain extent although it hasn't made any significant difference.

Server Details:
Core2Duo - (2 processors)
2GB DDRII RAM
WHM/Cpanel + Easy Apache + MySQL 5.1
PHP module - suPHP, PHP 5.2.9

Can anyone help me please to optimize it further?
optimushunk Reviewed by optimushunk on . Optimizing MySQL and Apache - Help Hello, I have been having some load issues with my server due to the response time in the MySQL server (I suspect that it is due to that). The load hits to 15/20 at peak hours (like just about 2 hours) and is below 1 most of the time. I have been tracking down the process on what is causing it and it seems it is the ajax chat on about 3 websites on the server. I would like to optimize the server in such a way that the ajax chat does not cause any issue to the server and slow down the other Rating: 5