kmike
Thu 13th Jan '05, 8:06am
We have a fairly big board (3100K posts, 53k users). It is running almost smoothly, except for one problem which plagues our db server: there're some queries in mysql slow log which are really shouldn't be there. For example, from yesterday's slow log:
# Time: 050112 20:34:11
# User@Host: xxxx[xxxx] @ [12.13.14.15]
# Query_time: 9 Lock_time: 0 Rows_sent: 0 Rows_examined: 0
UPDATE LOW_PRIORITY user
SET lastactivity = 1105580042
WHERE userid = 28929;
# Time: 050112 21:48:11
# User@Host: xxxx[xxxx] @ [12.13.14.15]
# Query_time: 9 Lock_time: 0 Rows_sent: 3 Rows_examined: 12
SELECT filename, filesize, visible, attachmentid, counter, postid, IF(thumbnail
= '', 0, 1) AS hasthumbnail, LENGTH(thumbnail) AS thumbnailsize
FROM attachment
WHERE postid IN (-1,1236301,1236314,1236403,1236461,1236492,1236497, 1236533,1236914,1238763,1239156,1241394,1242044,12 44250,1244321,1244668)
ORDER BY dateline;
# Time: 050112 21:49:29
# User@Host: xxxx[xxxx] @ [12.13.14.15]
# Query_time: 16 Lock_time: 0 Rows_sent: 0 Rows_examined: 0
SELECT title, data
FROM datastore
WHERE title IN ('options', 'forumcache', 'usergroupcache', 'stylecache', 'rankphp', 'smiliecache', 'bbcodecache', 'mailqueue', 'hidprofilecache');
# Time: 050112 23:03:11
# User@Host: xxxx[xxxx] @ [12.13.14.15]
# Query_time: 9 Lock_time: 0 Rows_sent: 0 Rows_examined: 0
INSERT INTO session
(sessionhash, userid, host, useragent, idhash, lastactivity, location, bypass, styleid
,inforum, inthread, incalendar, badlocation
)
VALUES
('a4f9908f49230572f69aa82d8edae510', 941,
'198.81.26.43', 'Mozilla/4.0 (compatible; MSIE 6.0; AOL 9.0; Windows NT 5.1; SV1)', '8beaf3a82482022236939504e872c62b',
1105588982, '/forums/forumdisplay.php?f=11&page=2&sort=lastpost&order=&pp=25&daysprune=20', 0, 0
,11, 0, 0,0
);
# Time: 050112 23:03:12
# User@Host: xxxx[xxxx] @ [12.13.14.15]
# Query_time: 10 Lock_time: 0 Rows_sent: 0 Rows_examined: 0
UPDATE LOW_PRIORITY user
SET lastactivity = 1105588982
WHERE userid = 44143;
# Time: 050112 23:40:14
# User@Host: rcgroups[rcgroups] @ [12.156.2.43]
# Query_time: 13 Lock_time: 0 Rows_sent: 0 Rows_examined: 0
INSERT INTO threadviews (threadid)
VALUES (317350);
You get the idea. These queries shouldn't lock anything, and are not locked according to "Lock_time:" value. Especially puzzling are session related queries.
These "hiccups" are sometimes causing apache processes to stack up, raising web frontend load.
There aren't any peaks of db server load or disk I/O activity associated with these queries:
sar -q output for corresponding time periods:
00:00:00 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15
.....
20:30:00 1 121 0.26 0.35 0.35
20:35:00 1 124 0.58 0.42 0.38
20:40:00 1 124 0.58 0.46 0.39
....
21:35:00 2 126 0.85 0.60 0.44
21:40:00 2 127 0.38 0.44 0.41
21:45:00 1 127 0.57 0.51 0.44
....
23:00:00 1 122 0.20 0.43 0.50
23:05:00 3 123 0.35 0.45 0.48
....
23:35:00 1 139 0.92 0.52 0.41
23:40:00 0 132 0.33 0.38 0.38
23:45:00 2 132 0.53 0.43 0.39
sar -b output:
00:00:00 tps rtps wtps bread/s bwrtn/s
...
20:25:00 24.97 8.34 16.63 99.72 180.72
20:30:00 24.58 6.93 17.65 82.16 194.09
20:35:00 25.41 7.59 17.83 89.61 195.07
...
21:30:01 29.59 11.39 18.20 136.69 200.47
21:35:00 37.50 11.11 26.38 132.68 291.42
21:40:00 29.71 12.19 17.52 148.79 189.79
...
22:55:00 33.71 14.13 19.58 164.77 213.14
23:00:00 29.43 10.63 18.80 134.20 204.61
23:05:00 29.23 7.81 21.42 93.20 234.48
....
23:35:00 30.87 9.21 21.66 107.58 236.41
23:40:00 23.51 8.92 14.59 111.87 159.18
23:45:00 29.85 8.79 21.06 112.63 232.48
I believe the server is fairly tweaked, but I'm all open to suggestions - maybe I've missed something obvious?
1. Dedicated db server, only mysql running
2. Specs:
Dual 2.4GHz Xeon HT
2Gb RAM
4x7200RPM IDE drives in RAID5
Redhat9 (we plan to upgrade to FC2 or FC3 with kernel 2.6.x ASAP)
Mysql 4.0.23
3. No InnoDB tables
4. Official RPMs provided by MySQL
5. top stats:
top - 06:19:30 up 19 days, 13:02, 4 users, load average: 0.27, 0.27, 0.26
Tasks: 117 total, 1 running, 116 sleeping, 0 stopped, 0 zombie
Cpu0 : 0.3% user, 2.7% system, 0.0% nice, 97.0% idle
Cpu1 : 4.7% user, 2.7% system, 0.0% nice, 92.7% idle
Cpu2 : 0.7% user, 2.3% system, 0.0% nice, 97.0% idle
Cpu3 : 1.3% user, 0.7% system, 0.0% nice, 98.0% idle
Mem: 2064644k total, 2053736k used, 10908k free, 31204k buffers
Swap: 2040244k total, 177572k used, 1862672k free, 1630412k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
25231 mysql 12 0 325m 280m 1532 S 6.0 13.9 0:22.22 mysqld
25588 mysql 12 0 325m 280m 1532 S 6.0 13.9 0:11.39 mysqld
10326 mysql 11 0 325m 280m 1532 S 2.0 13.9 4:21.81 mysqld
26564 root 16 0 884 884 668 R 2.0 0.0 0:00.02 top
1 root 8 0 456 428 396 S 0.0 0.0 0:18.35 init
2 root 9 0 0 0 0 S 0.0 0.0 0:09.55 keventd
3 root 19 19 0 0 0 S 0.0 0.0 0:03.72 ksoftirqd_CPU0
4 root 19 19 0 0 0 S 0.0 0.0 0:00.64 ksoftirqd_CPU1
5 root 19 19 0 0 0 S 0.0 0.0 0:00.40 ksoftirqd_CPU2
6 root 19 19 0 0 0 S 0.0 0.0 0:00.47 ksoftirqd_CPU3
7 root 9 0 0 0 0 S 0.0 0.0 11:08.98 kswapd
8 root 9 0 0 0 0 S 0.0 0.0 0:31.53 kscand/DMA
9 root 9 0 0 0 0 S 0.0 0.0 55:35.09 kscand/Normal
10 root 14 0 0 0 0 S 0.0 0.0 87:47.07 kscand/HighMem
11 root 9 0 0 0 0 S 0.0 0.0 0:00.49 bdflush
12 root 9 0 0 0 0 S 0.0 0.0 0:48.79 kupdated
13 root -1 -20 0 0 0 S 0.0 0.0 0:00.00 mdrecoveryd
19 root 9 0 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_0
22 root 9 0 0 0 0 S 0.0 0.0 0:08.62 kjournald
78 root 9 0 0 0 0 S 0.0 0.0 0:00.00 khubd
234 root 9 0 0 0 0 S 0.0 0.0 0:00.17 kjournald
235 root 9 0 0 0 0 S 0.0 0.0 1:27.74 kjournald
236 root 9 0 0 0 0 S 0.0 0.0 5:51.34 kjournald
237 root 9 0 0 0 0 S 0.0 0.0 0:25.89 kjournald
715 root 9 0 48 4 0 S 0.0 0.0 0:00.00 mingetty
716 root 9 0 48 4 0 S 0.0 0.0 0:00.01 mingetty
717 root 9 0 48 4 0 S 0.0 0.0 0:00.00 mingetty
718 root 9 0 48 4 0 S 0.0 0.0 0:00.00 mingetty
719 root 9 0 48 4 0 S 0.0 0.0 0:00.01 mingetty
869 root 9 0 48 4 0 S 0.0 0.0 0:00.00 mingetty
21208 supporte 10 0 1548 816 496 S 0.0 0.0 0:05.07 screen
21209 root 17 0 876 752 520 S 0.0 0.0 0:15.74 bash
21211 supporte 9 0 320 64 60 S 0.0 0.0 0:00.01 bash
21213 supporte 9 0 720 444 440 S 0.0 0.0 0:00.14 bash
2617 supporte 9 0 1212 276 272 S 0.0 0.0 0:01.20 mysql
6489 daemon 19 19 560 524 484 S 0.0 0.0 0:00.08 atd
6720 root 19 19 484 416 412 S 0.0 0.0 0:00.01 gpm
6739 root 18 19 596 548 500 S 0.0 0.0 0:01.86 crond
6784 root 19 19 556 524 472 S 0.0 0.0 0:02.51 syslogd
6788 root 19 19 424 368 364 S 0.0 0.0 0:00.01 klogd
6815 root 18 19 748 688 612 S 0.0 0.0 0:01.07 xinetd
6857 root 19 19 1712 1196 1004 S 0.0 0.1 0:13.06 sendmail
6867 smmsp 18 19 1420 972 856 S 0.0 0.0 0:00.28 sendmail
8157 root 9 0 968 812 704 S 0.0 0.0 0:15.85 sshd
10298 root 9 0 980 836 832 S 0.0 0.0 0:00.00 mysqld_safe
10318 mysql 9 0 325m 280m 1532 S 0.0 13.9 1:31.76 mysqld
10319 mysql 9 0 325m 280m 1532 S 0.0 13.9 0:02.42 mysqld
10320 mysql 9 0 325m 280m 1532 S 0.0 13.9 1:20.43 mysqld
10321 mysql 9 0 325m 280m 1532 S 0.0 13.9 0:02.32 mysqld
10322 mysql 9 0 325m 280m 1532 S 0.0 13.9 0:06.27 mysqld
10325 mysql 9 0 325m 280m 1532 S 0.0 13.9 4:12.63 mysqld
23745 mysql 10 0 325m 280m 1532 S 0.0 13.9 1:27.29 mysqld
24350 mysql 9 0 325m 280m 1532 S 0.0 13.9 0:56.74 mysqld
24529 mysql 9 0 325m 280m 1532 S 0.0 13.9 0:51.96 mysqld
24644 mysql 10 0 325m 280m 1532 S 0.0 13.9 0:42.14 mysqld
24784 root 9 0 2008 1928 1592 S 0.0 0.1 0:00.02 sshd
24786 supporte 9 0 2464 2396 2016 S 0.0 0.1 0:00.03 sshd
24787 supporte 9 0 1024 952 804 S 0.0 0.0 0:00.07 screen
24914 mysql 9 0 325m 280m 1532 S 0.0 13.9 0:28.21 mysqld
...... (80 more mysqld's)
Preventing the question of rather high swap usage - it stabilizes on that value after a few days of uptime, sar -W shows almost zero swapping - avg 0.3 page/sec at peak time.
6. my.cnf
[mysqld]
back_log=128
tmpdir=/usr/mysql/tmp
ft_min_word_len=3
long_query_time=8
max_connections=300
key_buffer_size=224M
myisam_sort_buffer_size=64M
join_buffer_size=1M
read_buffer_size=1M
read_rnd_buffer_size=1M
sort_buffer_size=2M
table_cache=1536
thread_cache_size=64
wait_timeout=1800
connect_timeout=5
max_allowed_packet=16M
max_connect_errors=16
tmp_table_size=32M
query_prealloc_size=16384
query_cache_limit = 512K
query_cache_size = 48M
query_cache_type = 1
skip-innodb
log-slow-queries = /usr/mysql/mysqld.slow.log
server-id=1
skip-name-resolve
skip-external-locking
log-bin
binlog-ignore-db = mysql
binlog-ignore-db = test
binlog-ignore-db = phpads
max_binlog_size=120M
replicate-do-db = forums2
replicate-do-db = fogbugz
[myisamchk]
ft_min_word_len=3
tmpdir=/usr/mysql/tmp
key_buffer=128M
sort_buffer=128M
read_buffer=16M
write_buffer=16M
[mysqld_safe]
open_files_limit = 8192
This server also replicates two very low-traffic db's, but the problem were there even before replication setup.
7. mysql status
+--------------------------+------------+
| Variable_name | Value |
+--------------------------+------------+
| Aborted_clients | 124 |
| Aborted_connects | 603 |
| Bytes_received | 2005496256 |
| Bytes_sent | 655370742 |
| Com_admin_commands | 3 |
| Com_alter_table | 2 |
| Com_analyze | 0 |
| Com_backup_table | 0 |
| Com_begin | 0 |
| Com_change_db | 1580240 |
| Com_change_master | 0 |
| Com_check | 0 |
| Com_commit | 0 |
| Com_create_db | 0 |
| Com_create_function | 0 |
| Com_create_index | 0 |
| Com_create_table | 629 |
| Com_delete | 91462 |
| Com_delete_multi | 1 |
| Com_drop_db | 0 |
| Com_drop_function | 0 |
| Com_drop_index | 0 |
| Com_drop_table | 20426 |
| Com_flush | 2 |
| Com_grant | 0 |
| Com_ha_close | 0 |
| Com_ha_open | 0 |
| Com_ha_read | 0 |
| Com_insert | 1260663 |
| Com_insert_select | 56 |
| Com_kill | 0 |
| Com_load | 0 |
| Com_load_master_data | 0 |
| Com_load_master_table | 0 |
| Com_lock_tables | 0 |
| Com_optimize | 0 |
| Com_purge | 0 |
| Com_rename_table | 0 |
| Com_repair | 0 |
| Com_replace | 43908 |
| Com_replace_select | 0 |
| Com_reset | 0 |
| Com_restore_table | 0 |
| Com_revoke | 0 |
| Com_rollback | 0 |
| Com_savepoint | 0 |
| Com_select | 7053655 |
| Com_set_option | 46 |
| Com_show_binlog_events | 0 |
| Com_show_binlogs | 0 |
| Com_show_create | 48 |
| Com_show_databases | 3 |
| Com_show_fields | 471 |
| Com_show_grants | 0 |
| Com_show_keys | 1 |
| Com_show_logs | 0 |
| Com_show_master_status | 0 |
| Com_show_new_master | 0 |
| Com_show_open_tables | 0 |
| Com_show_processlist | 1 |
| Com_show_slave_hosts | 3 |
| Com_show_slave_status | 1 |
| Com_show_status | 13 |
| Com_show_innodb_status | 0 |
| Com_show_tables | 2184 |
| Com_show_variables | 13 |
| Com_slave_start | 0 |
| Com_slave_stop | 0 |
| Com_truncate | 0 |
| Com_unlock_tables | 0 |
| Com_update | 3241108 |
| Connections | 1572205 |
| Created_tmp_disk_tables | 13764 |
| Created_tmp_tables | 115884 |
| Created_tmp_files | 302 |
| Delayed_insert_threads | 0 |
| Delayed_writes | 0 |
| Delayed_errors | 0 |
| Flush_commands | 1 |
| Handler_commit | 0 |
| Handler_delete | 201375 |
| Handler_read_first | 1263542 |
| Handler_read_key | 1257946078 |
| Handler_read_next | 1627686487 |
| Handler_read_prev | 18178446 |
| Handler_read_rnd | 130484965 |
| Handler_read_rnd_next | 633030589 |
| Handler_rollback | 0 |
| Handler_update | 6190963 |
| Handler_write | 18077357 |
| Key_blocks_used | 217962 | Approx. 95% of key_buffer_size in use
| Key_read_requests | 2821061676 |
| Key_reads | 262450 |
| Key_write_requests | 6710893 |
| Key_writes | 2274141 |
| Max_used_connections | 208 |
| Not_flushed_key_blocks | 0 |
| Not_flushed_delayed_rows | 0 |
| Open_tables | 1530 | 100% of table_cache in use
| Open_files | 1697 |
| Open_streams | 0 |
| Opened_tables | 3560 |
| Questions | 24537432 |
| Qcache_queries_in_cache | 13878 |
| Qcache_inserts | 6973628 |
| Qcache_hits | 9665613 |
| Qcache_lowmem_prunes | 79216 |
| Qcache_not_cached | 80024 |
| Qcache_free_memory | 26210016 | 23556.3K (approx. 47.9%) of query_cache_size in use
| Qcache_free_blocks | 3249 |
| Qcache_total_blocks | 31466 |
| Rpl_status | NULL |
| Select_full_join | 431 |
| Select_full_range_join | 21 |
| Select_range | 1208995 |
| Select_range_check | 0 |
| Select_scan | 471712 |
| Slave_open_temp_tables | 0 |
| Slave_running | ON |
| Slow_launch_threads | 9 |
| Slow_queries | 898 | (execution time > 8 secs)
| Sort_merge_passes | 148 |
| Sort_range | 1338900 |
| Sort_rows | 492135122 |
| Sort_scan | 311571 |
| Table_locks_immediate | 22522677 |
| Table_locks_waited | 199713 |
| Threads_cached | 43 |
| Threads_created | 5435 |
| Threads_connected | 23 |
| Threads_running | 3 |
| Uptime | 179513 | 2 days 1 hr 51 mins 53 secs
+--------------------------+------------+
Key Reads/Key Read Requests = 0.000093 (Cache hit = 99.999907%)
Key Writes/Key Write Requests = 0.338873
Connections/second = 8.758 (/hour = 31529.405)
KB received/second = 10.910 (/hour = 39276.104)
KB sent/second = 3.565 (/hour = 12834.926)
Temporary Tables Created/second = 0.646 (/hour = 2323.968)
Opened Tables/second = 0.020 (/hour = 71.393)
Slow Queries/second = 0.005 (/hour = 18.009)
% of slow queries = 0.004%
Queries/second = 136.689 (/hour = 492079.990)
Query Cache Hit Rate = 9665613/16719268 (57.811221%)
Waited Query Locks Ratio = 199713/22722390 (0.878926%)
Temp Tables Created on Disk Ratio = 13764/129648 (10.616438%)
8. vB isn't the only thing accessing this db server, but other scripts' queries are almost non-existant compared with vB.
9. Forum users: average 1100 at day time, peak was about 1500 per 900secs cookie timeout
10-11. Does php and apache config matter here?
# Time: 050112 20:34:11
# User@Host: xxxx[xxxx] @ [12.13.14.15]
# Query_time: 9 Lock_time: 0 Rows_sent: 0 Rows_examined: 0
UPDATE LOW_PRIORITY user
SET lastactivity = 1105580042
WHERE userid = 28929;
# Time: 050112 21:48:11
# User@Host: xxxx[xxxx] @ [12.13.14.15]
# Query_time: 9 Lock_time: 0 Rows_sent: 3 Rows_examined: 12
SELECT filename, filesize, visible, attachmentid, counter, postid, IF(thumbnail
= '', 0, 1) AS hasthumbnail, LENGTH(thumbnail) AS thumbnailsize
FROM attachment
WHERE postid IN (-1,1236301,1236314,1236403,1236461,1236492,1236497, 1236533,1236914,1238763,1239156,1241394,1242044,12 44250,1244321,1244668)
ORDER BY dateline;
# Time: 050112 21:49:29
# User@Host: xxxx[xxxx] @ [12.13.14.15]
# Query_time: 16 Lock_time: 0 Rows_sent: 0 Rows_examined: 0
SELECT title, data
FROM datastore
WHERE title IN ('options', 'forumcache', 'usergroupcache', 'stylecache', 'rankphp', 'smiliecache', 'bbcodecache', 'mailqueue', 'hidprofilecache');
# Time: 050112 23:03:11
# User@Host: xxxx[xxxx] @ [12.13.14.15]
# Query_time: 9 Lock_time: 0 Rows_sent: 0 Rows_examined: 0
INSERT INTO session
(sessionhash, userid, host, useragent, idhash, lastactivity, location, bypass, styleid
,inforum, inthread, incalendar, badlocation
)
VALUES
('a4f9908f49230572f69aa82d8edae510', 941,
'198.81.26.43', 'Mozilla/4.0 (compatible; MSIE 6.0; AOL 9.0; Windows NT 5.1; SV1)', '8beaf3a82482022236939504e872c62b',
1105588982, '/forums/forumdisplay.php?f=11&page=2&sort=lastpost&order=&pp=25&daysprune=20', 0, 0
,11, 0, 0,0
);
# Time: 050112 23:03:12
# User@Host: xxxx[xxxx] @ [12.13.14.15]
# Query_time: 10 Lock_time: 0 Rows_sent: 0 Rows_examined: 0
UPDATE LOW_PRIORITY user
SET lastactivity = 1105588982
WHERE userid = 44143;
# Time: 050112 23:40:14
# User@Host: rcgroups[rcgroups] @ [12.156.2.43]
# Query_time: 13 Lock_time: 0 Rows_sent: 0 Rows_examined: 0
INSERT INTO threadviews (threadid)
VALUES (317350);
You get the idea. These queries shouldn't lock anything, and are not locked according to "Lock_time:" value. Especially puzzling are session related queries.
These "hiccups" are sometimes causing apache processes to stack up, raising web frontend load.
There aren't any peaks of db server load or disk I/O activity associated with these queries:
sar -q output for corresponding time periods:
00:00:00 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15
.....
20:30:00 1 121 0.26 0.35 0.35
20:35:00 1 124 0.58 0.42 0.38
20:40:00 1 124 0.58 0.46 0.39
....
21:35:00 2 126 0.85 0.60 0.44
21:40:00 2 127 0.38 0.44 0.41
21:45:00 1 127 0.57 0.51 0.44
....
23:00:00 1 122 0.20 0.43 0.50
23:05:00 3 123 0.35 0.45 0.48
....
23:35:00 1 139 0.92 0.52 0.41
23:40:00 0 132 0.33 0.38 0.38
23:45:00 2 132 0.53 0.43 0.39
sar -b output:
00:00:00 tps rtps wtps bread/s bwrtn/s
...
20:25:00 24.97 8.34 16.63 99.72 180.72
20:30:00 24.58 6.93 17.65 82.16 194.09
20:35:00 25.41 7.59 17.83 89.61 195.07
...
21:30:01 29.59 11.39 18.20 136.69 200.47
21:35:00 37.50 11.11 26.38 132.68 291.42
21:40:00 29.71 12.19 17.52 148.79 189.79
...
22:55:00 33.71 14.13 19.58 164.77 213.14
23:00:00 29.43 10.63 18.80 134.20 204.61
23:05:00 29.23 7.81 21.42 93.20 234.48
....
23:35:00 30.87 9.21 21.66 107.58 236.41
23:40:00 23.51 8.92 14.59 111.87 159.18
23:45:00 29.85 8.79 21.06 112.63 232.48
I believe the server is fairly tweaked, but I'm all open to suggestions - maybe I've missed something obvious?
1. Dedicated db server, only mysql running
2. Specs:
Dual 2.4GHz Xeon HT
2Gb RAM
4x7200RPM IDE drives in RAID5
Redhat9 (we plan to upgrade to FC2 or FC3 with kernel 2.6.x ASAP)
Mysql 4.0.23
3. No InnoDB tables
4. Official RPMs provided by MySQL
5. top stats:
top - 06:19:30 up 19 days, 13:02, 4 users, load average: 0.27, 0.27, 0.26
Tasks: 117 total, 1 running, 116 sleeping, 0 stopped, 0 zombie
Cpu0 : 0.3% user, 2.7% system, 0.0% nice, 97.0% idle
Cpu1 : 4.7% user, 2.7% system, 0.0% nice, 92.7% idle
Cpu2 : 0.7% user, 2.3% system, 0.0% nice, 97.0% idle
Cpu3 : 1.3% user, 0.7% system, 0.0% nice, 98.0% idle
Mem: 2064644k total, 2053736k used, 10908k free, 31204k buffers
Swap: 2040244k total, 177572k used, 1862672k free, 1630412k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
25231 mysql 12 0 325m 280m 1532 S 6.0 13.9 0:22.22 mysqld
25588 mysql 12 0 325m 280m 1532 S 6.0 13.9 0:11.39 mysqld
10326 mysql 11 0 325m 280m 1532 S 2.0 13.9 4:21.81 mysqld
26564 root 16 0 884 884 668 R 2.0 0.0 0:00.02 top
1 root 8 0 456 428 396 S 0.0 0.0 0:18.35 init
2 root 9 0 0 0 0 S 0.0 0.0 0:09.55 keventd
3 root 19 19 0 0 0 S 0.0 0.0 0:03.72 ksoftirqd_CPU0
4 root 19 19 0 0 0 S 0.0 0.0 0:00.64 ksoftirqd_CPU1
5 root 19 19 0 0 0 S 0.0 0.0 0:00.40 ksoftirqd_CPU2
6 root 19 19 0 0 0 S 0.0 0.0 0:00.47 ksoftirqd_CPU3
7 root 9 0 0 0 0 S 0.0 0.0 11:08.98 kswapd
8 root 9 0 0 0 0 S 0.0 0.0 0:31.53 kscand/DMA
9 root 9 0 0 0 0 S 0.0 0.0 55:35.09 kscand/Normal
10 root 14 0 0 0 0 S 0.0 0.0 87:47.07 kscand/HighMem
11 root 9 0 0 0 0 S 0.0 0.0 0:00.49 bdflush
12 root 9 0 0 0 0 S 0.0 0.0 0:48.79 kupdated
13 root -1 -20 0 0 0 S 0.0 0.0 0:00.00 mdrecoveryd
19 root 9 0 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_0
22 root 9 0 0 0 0 S 0.0 0.0 0:08.62 kjournald
78 root 9 0 0 0 0 S 0.0 0.0 0:00.00 khubd
234 root 9 0 0 0 0 S 0.0 0.0 0:00.17 kjournald
235 root 9 0 0 0 0 S 0.0 0.0 1:27.74 kjournald
236 root 9 0 0 0 0 S 0.0 0.0 5:51.34 kjournald
237 root 9 0 0 0 0 S 0.0 0.0 0:25.89 kjournald
715 root 9 0 48 4 0 S 0.0 0.0 0:00.00 mingetty
716 root 9 0 48 4 0 S 0.0 0.0 0:00.01 mingetty
717 root 9 0 48 4 0 S 0.0 0.0 0:00.00 mingetty
718 root 9 0 48 4 0 S 0.0 0.0 0:00.00 mingetty
719 root 9 0 48 4 0 S 0.0 0.0 0:00.01 mingetty
869 root 9 0 48 4 0 S 0.0 0.0 0:00.00 mingetty
21208 supporte 10 0 1548 816 496 S 0.0 0.0 0:05.07 screen
21209 root 17 0 876 752 520 S 0.0 0.0 0:15.74 bash
21211 supporte 9 0 320 64 60 S 0.0 0.0 0:00.01 bash
21213 supporte 9 0 720 444 440 S 0.0 0.0 0:00.14 bash
2617 supporte 9 0 1212 276 272 S 0.0 0.0 0:01.20 mysql
6489 daemon 19 19 560 524 484 S 0.0 0.0 0:00.08 atd
6720 root 19 19 484 416 412 S 0.0 0.0 0:00.01 gpm
6739 root 18 19 596 548 500 S 0.0 0.0 0:01.86 crond
6784 root 19 19 556 524 472 S 0.0 0.0 0:02.51 syslogd
6788 root 19 19 424 368 364 S 0.0 0.0 0:00.01 klogd
6815 root 18 19 748 688 612 S 0.0 0.0 0:01.07 xinetd
6857 root 19 19 1712 1196 1004 S 0.0 0.1 0:13.06 sendmail
6867 smmsp 18 19 1420 972 856 S 0.0 0.0 0:00.28 sendmail
8157 root 9 0 968 812 704 S 0.0 0.0 0:15.85 sshd
10298 root 9 0 980 836 832 S 0.0 0.0 0:00.00 mysqld_safe
10318 mysql 9 0 325m 280m 1532 S 0.0 13.9 1:31.76 mysqld
10319 mysql 9 0 325m 280m 1532 S 0.0 13.9 0:02.42 mysqld
10320 mysql 9 0 325m 280m 1532 S 0.0 13.9 1:20.43 mysqld
10321 mysql 9 0 325m 280m 1532 S 0.0 13.9 0:02.32 mysqld
10322 mysql 9 0 325m 280m 1532 S 0.0 13.9 0:06.27 mysqld
10325 mysql 9 0 325m 280m 1532 S 0.0 13.9 4:12.63 mysqld
23745 mysql 10 0 325m 280m 1532 S 0.0 13.9 1:27.29 mysqld
24350 mysql 9 0 325m 280m 1532 S 0.0 13.9 0:56.74 mysqld
24529 mysql 9 0 325m 280m 1532 S 0.0 13.9 0:51.96 mysqld
24644 mysql 10 0 325m 280m 1532 S 0.0 13.9 0:42.14 mysqld
24784 root 9 0 2008 1928 1592 S 0.0 0.1 0:00.02 sshd
24786 supporte 9 0 2464 2396 2016 S 0.0 0.1 0:00.03 sshd
24787 supporte 9 0 1024 952 804 S 0.0 0.0 0:00.07 screen
24914 mysql 9 0 325m 280m 1532 S 0.0 13.9 0:28.21 mysqld
...... (80 more mysqld's)
Preventing the question of rather high swap usage - it stabilizes on that value after a few days of uptime, sar -W shows almost zero swapping - avg 0.3 page/sec at peak time.
6. my.cnf
[mysqld]
back_log=128
tmpdir=/usr/mysql/tmp
ft_min_word_len=3
long_query_time=8
max_connections=300
key_buffer_size=224M
myisam_sort_buffer_size=64M
join_buffer_size=1M
read_buffer_size=1M
read_rnd_buffer_size=1M
sort_buffer_size=2M
table_cache=1536
thread_cache_size=64
wait_timeout=1800
connect_timeout=5
max_allowed_packet=16M
max_connect_errors=16
tmp_table_size=32M
query_prealloc_size=16384
query_cache_limit = 512K
query_cache_size = 48M
query_cache_type = 1
skip-innodb
log-slow-queries = /usr/mysql/mysqld.slow.log
server-id=1
skip-name-resolve
skip-external-locking
log-bin
binlog-ignore-db = mysql
binlog-ignore-db = test
binlog-ignore-db = phpads
max_binlog_size=120M
replicate-do-db = forums2
replicate-do-db = fogbugz
[myisamchk]
ft_min_word_len=3
tmpdir=/usr/mysql/tmp
key_buffer=128M
sort_buffer=128M
read_buffer=16M
write_buffer=16M
[mysqld_safe]
open_files_limit = 8192
This server also replicates two very low-traffic db's, but the problem were there even before replication setup.
7. mysql status
+--------------------------+------------+
| Variable_name | Value |
+--------------------------+------------+
| Aborted_clients | 124 |
| Aborted_connects | 603 |
| Bytes_received | 2005496256 |
| Bytes_sent | 655370742 |
| Com_admin_commands | 3 |
| Com_alter_table | 2 |
| Com_analyze | 0 |
| Com_backup_table | 0 |
| Com_begin | 0 |
| Com_change_db | 1580240 |
| Com_change_master | 0 |
| Com_check | 0 |
| Com_commit | 0 |
| Com_create_db | 0 |
| Com_create_function | 0 |
| Com_create_index | 0 |
| Com_create_table | 629 |
| Com_delete | 91462 |
| Com_delete_multi | 1 |
| Com_drop_db | 0 |
| Com_drop_function | 0 |
| Com_drop_index | 0 |
| Com_drop_table | 20426 |
| Com_flush | 2 |
| Com_grant | 0 |
| Com_ha_close | 0 |
| Com_ha_open | 0 |
| Com_ha_read | 0 |
| Com_insert | 1260663 |
| Com_insert_select | 56 |
| Com_kill | 0 |
| Com_load | 0 |
| Com_load_master_data | 0 |
| Com_load_master_table | 0 |
| Com_lock_tables | 0 |
| Com_optimize | 0 |
| Com_purge | 0 |
| Com_rename_table | 0 |
| Com_repair | 0 |
| Com_replace | 43908 |
| Com_replace_select | 0 |
| Com_reset | 0 |
| Com_restore_table | 0 |
| Com_revoke | 0 |
| Com_rollback | 0 |
| Com_savepoint | 0 |
| Com_select | 7053655 |
| Com_set_option | 46 |
| Com_show_binlog_events | 0 |
| Com_show_binlogs | 0 |
| Com_show_create | 48 |
| Com_show_databases | 3 |
| Com_show_fields | 471 |
| Com_show_grants | 0 |
| Com_show_keys | 1 |
| Com_show_logs | 0 |
| Com_show_master_status | 0 |
| Com_show_new_master | 0 |
| Com_show_open_tables | 0 |
| Com_show_processlist | 1 |
| Com_show_slave_hosts | 3 |
| Com_show_slave_status | 1 |
| Com_show_status | 13 |
| Com_show_innodb_status | 0 |
| Com_show_tables | 2184 |
| Com_show_variables | 13 |
| Com_slave_start | 0 |
| Com_slave_stop | 0 |
| Com_truncate | 0 |
| Com_unlock_tables | 0 |
| Com_update | 3241108 |
| Connections | 1572205 |
| Created_tmp_disk_tables | 13764 |
| Created_tmp_tables | 115884 |
| Created_tmp_files | 302 |
| Delayed_insert_threads | 0 |
| Delayed_writes | 0 |
| Delayed_errors | 0 |
| Flush_commands | 1 |
| Handler_commit | 0 |
| Handler_delete | 201375 |
| Handler_read_first | 1263542 |
| Handler_read_key | 1257946078 |
| Handler_read_next | 1627686487 |
| Handler_read_prev | 18178446 |
| Handler_read_rnd | 130484965 |
| Handler_read_rnd_next | 633030589 |
| Handler_rollback | 0 |
| Handler_update | 6190963 |
| Handler_write | 18077357 |
| Key_blocks_used | 217962 | Approx. 95% of key_buffer_size in use
| Key_read_requests | 2821061676 |
| Key_reads | 262450 |
| Key_write_requests | 6710893 |
| Key_writes | 2274141 |
| Max_used_connections | 208 |
| Not_flushed_key_blocks | 0 |
| Not_flushed_delayed_rows | 0 |
| Open_tables | 1530 | 100% of table_cache in use
| Open_files | 1697 |
| Open_streams | 0 |
| Opened_tables | 3560 |
| Questions | 24537432 |
| Qcache_queries_in_cache | 13878 |
| Qcache_inserts | 6973628 |
| Qcache_hits | 9665613 |
| Qcache_lowmem_prunes | 79216 |
| Qcache_not_cached | 80024 |
| Qcache_free_memory | 26210016 | 23556.3K (approx. 47.9%) of query_cache_size in use
| Qcache_free_blocks | 3249 |
| Qcache_total_blocks | 31466 |
| Rpl_status | NULL |
| Select_full_join | 431 |
| Select_full_range_join | 21 |
| Select_range | 1208995 |
| Select_range_check | 0 |
| Select_scan | 471712 |
| Slave_open_temp_tables | 0 |
| Slave_running | ON |
| Slow_launch_threads | 9 |
| Slow_queries | 898 | (execution time > 8 secs)
| Sort_merge_passes | 148 |
| Sort_range | 1338900 |
| Sort_rows | 492135122 |
| Sort_scan | 311571 |
| Table_locks_immediate | 22522677 |
| Table_locks_waited | 199713 |
| Threads_cached | 43 |
| Threads_created | 5435 |
| Threads_connected | 23 |
| Threads_running | 3 |
| Uptime | 179513 | 2 days 1 hr 51 mins 53 secs
+--------------------------+------------+
Key Reads/Key Read Requests = 0.000093 (Cache hit = 99.999907%)
Key Writes/Key Write Requests = 0.338873
Connections/second = 8.758 (/hour = 31529.405)
KB received/second = 10.910 (/hour = 39276.104)
KB sent/second = 3.565 (/hour = 12834.926)
Temporary Tables Created/second = 0.646 (/hour = 2323.968)
Opened Tables/second = 0.020 (/hour = 71.393)
Slow Queries/second = 0.005 (/hour = 18.009)
% of slow queries = 0.004%
Queries/second = 136.689 (/hour = 492079.990)
Query Cache Hit Rate = 9665613/16719268 (57.811221%)
Waited Query Locks Ratio = 199713/22722390 (0.878926%)
Temp Tables Created on Disk Ratio = 13764/129648 (10.616438%)
8. vB isn't the only thing accessing this db server, but other scripts' queries are almost non-existant compared with vB.
9. Forum users: average 1100 at day time, peak was about 1500 per 900secs cookie timeout
10-11. Does php and apache config matter here?