w3-total-cache + memcached
经过测试发现WP在使用了w3-total-cache+memcached 缓存后,MYSQL 的压力明显降低。cpu 使用率从之前测试时的80%降至现在的10%以内。
下面是AB测试的结果:
enchmarking www.csxq.net (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: nginx/1.7.2
Server Hostname: www.csxq.net
Server Port: 80Document Path: /
Document Length: 19452 bytesConcurrency Level: 1000
Time taken for tests: 8.972 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 19990324 bytes
HTML transferred: 19520071 bytes
Requests per second: 111.46 [#/sec] (mean)
Time per request: 8971.649 [ms] (mean)
Time per request: 8.972 [ms] (mean, across all concurrent requests)
Transfer rate: 2175.94 [Kbytes/sec] receivedConnection Times (ms)
min mean[+/-sd] median max
Connect: 15 304 535.7 34 3055
Processing: 87 3626 1475.1 3339 8103
Waiting: 40 900 1095.1 334 6446
Total: 146 3930 1501.4 3712 8960Percentage of the requests served within a certain time (ms)
50% 3712
66% 4188
75% 4588
80% 4816
90% 5879
95% 6728
98% 8698
99% 8849
100% 8960 (longest request)
return array(
‘version’ => ‘0.9.4’,
‘cluster.messagebus.debug’ => false,
‘cluster.messagebus.enabled’ => false,
‘cluster.messagebus.sns.region’ => ”,
‘cluster.messagebus.sns.api_key’ => ”,
‘cluster.messagebus.sns.api_secret’ => ”,
‘cluster.messagebus.sns.topic_arn’ => ”,
‘dbcache.debug’ => false,
‘dbcache.enabled’ => true,
‘dbcache.engine’ => ‘memcached’,
‘dbcache.file.gc’ => 3600,
‘dbcache.file.locking’ => false,
‘dbcache.lifetime’ => 180,
‘dbcache.memcached.persistant’ => true,
‘dbcache.memcached.servers’ => array(
0 => ‘127.0.0.1:11211’,
),
‘dbcache.reject.cookie’ => array(
),
‘dbcache.reject.logged’ => true,
‘dbcache.reject.sql’ => array(
0 => ‘gdsr_’,
1 => ‘wp_rg_’,
2 => ‘_wp_session_’,
),
‘dbcache.reject.uri’ => array(
0 => ”,
),
‘dbcache.reject.words’ => array(
0 => ‘^\\s*insert\\b’,
1 => ‘^\\s*delete\\b’,
STAT pid 26080
STAT uptime 41627
STAT time 1404535278
STAT version 1.4.5
STAT pointer_size 64
STAT rusage_user 1.425783
STAT rusage_system 1.332797
STAT curr_connections 25
STAT total_connections 1951
STAT connection_structures 26
STAT cmd_get 2189
STAT cmd_set 1889
STAT cmd_flush 0
STAT get_hits 1126
STAT get_misses 1063
STAT delete_misses 7
STAT delete_hits 2
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 1605608
STAT bytes_written 2963857
STAT limit_maxbytes 524288000
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
不得不说缓存技术很重要啊。
启动:memcached -d -m 128 -u root -l 127.0.0.1 -p 11211 -c 2000 -P /tmp/memcached.pid
关闭:kill `cat /tmp/memcached.pid`
查看:echo stats | nc 127.0.0.111211
实时:watch “echo stats | nc 127.0.0.1 11211”
memcache 在Centos 下的安装很方便,直接使用epel 的源:
yum install -y memcached