Results 1 to 10 of 26
-
27th Apr 2010, 11:01 PM #1OPMember
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 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)
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
I have the:
Code:log_slow_queries = /var/log/mysql/mysql-slow.log
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 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
-
27th Apr 2010, 11:17 PM #2Respected Member
It is suggesting these changes:
Variables to adjust:
query_cache_size = 20M
join_buffer_size = 2.0M
tmp_table_size = 48M
max_heap_table_size = 48M
table_cache = 6192
innodb_buffer_pool_size = 32M
also add:
log_slow_queries = /var/log/mysql/mysql-slow.log
long_query_time = 2
log-queries-not-using-indexes
-
27th Apr 2010, 11:21 PM #3OPMember
Those three lines are already added. Thank you for looking into it
EDIT: I'll look into other variables. Just wrote down before you edited the previous post.
Changed, if there are any other suggestions, do let me know.
also add:
log_slow_queries = /var/log/mysql/mysql-slow.log
long_query_time = 2
log-queries-not-using-indexes
-
27th Apr 2010, 11:30 PM #4Respected Member
Let us know how it works out.
Also check the log and see how many ans which queries are not using indexes.
-
27th Apr 2010, 11:34 PM #5OPMember
I just checked, the path /var/log/mysql/mysql-slow.log does not exist on my server.
var/log/ is available while mysql/mysql-slow.log is not..
Shall I create the file up ? or is there some other path it should log to?
-
28th Apr 2010, 02:55 AM #6Respected Member
Yes you will need to create it.
-
28th Apr 2010, 08:10 PM #7MemberWebsite's:
GotMovies.net
-
3rd May 2010, 01:40 AM #8OPMember
New results from the tuners:
MySQLtuner.pl
Code:-------- General Statistics -------------------------------------------------- [--] Skipped version check for MySQLTuner script [OK] Currently running supported MySQL version 5.1.44-log [OK] Operating on 64-bit architecture -------- Storage Engine Statistics ------------------------------------------- [--] Status: -Archive -BDB -Federated +InnoDB -ISAM -NDBCluster [--] Data in MyISAM tables: 420M (Tables: 3712) [--] Data in InnoDB tables: 21M (Tables: 221) [--] Data in MEMORY tables: 1020K (Tables: 1) [!!] Total fragmented tables: 357 -------- Performance Metrics ------------------------------------------------- [--] Up for: 4d 4h 12m 19s (21M q [59.941 qps], 1M conn, TX: 63B, RX: 6B) [--] 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/21M) [OK] Highest usage of available connections: 23% (23/100) [OK] Key buffer size / total MyISAM indexes: 64.0M/92.0M [OK] Key buffer hit rate: 99.7% (117M cached / 388K reads) [OK] Query cache efficiency: 59.3% (8M cached / 14M selects) [!!] Query cache prunes per day: 73923 [OK] Sorts requiring temporary tables: 0% (0 temp sorts / 1M sorts) [!!] Joins performed without indexes: 18506 [!!] Temporary tables created on disk: 29% (46K on disk / 156K total) [OK] Thread cache hit rate: 99% (23 created / 1M connections) [!!] Table cache hit rate: 2% (3K open / 135K opened) [OK] Open file limit used: 8% (5K/65K) [OK] Table locks acquired immediately: 99% (11M immediate / 11M locks) [OK] InnoDB data size / buffer pool: 21.1M/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)
Code:SLOW QUERIES The slow query log is enabled. Current long_query_time = 2.000000 sec. You have 1828074 out of 21630997 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 = 21 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 = 23 The number of used connections is 23% 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 = 16 % 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 : 293 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 : 300 Key buffer free ratio = 80 % 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.94 % 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 18444 queries where a join could not use an index properly You have had 76 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 3957 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 109755 temp tables, 29% 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 = 24 : 1 read_buffer_size seems to be fine TABLE LOCKING Current Lock Wait ratio = 1 : 30643 Your table locking seems to be fine
@keytraderz
mod_cache is already complied with easyapache. Thank you for the suggestion.
-
3rd May 2010, 01:43 AM #9BannedWebsite's:
KWWHunction.comDid you edit
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)
As it said to do ? I always use this tool it is very helpful
-
3rd May 2010, 01:47 AM #10OPMember
Well yes, nearly:
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
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Public Rapidleech-Need help optimizing apache and php for performance of VPS
By Enigmatic in forum Server ManagementReplies: 1Last Post: 29th Sep 2011, 03:54 PM -
Public Rapidleech-Need help optimizing apache and php for performance of VPS
By Enigmatic in forum Technical Help Desk SupportReplies: 9Last Post: 29th Sep 2011, 03:40 PM -
Need help optimizing apache and php for performance of VPS for Public Rapidleech
By Enigmatic in forum Web Application/Script SupportReplies: 1Last Post: 29th Sep 2011, 02:27 PM -
Automatic reboot Apache and Mysql every x min, possible?
By DoctorX in forum Server ManagementReplies: 10Last Post: 8th Jul 2011, 03:36 PM -
Optimizing MySQL (Linux with DirectAdmin)
By Lease in forum Technical and Security TutorialsReplies: 0Last Post: 8th Jan 2008, 08:57 AM
themaLeecher - leech and manage...
Version 4.94 released. Open older version (or...