有些注定了被遗忘的话,也就有的注定了属于沉静的自私.

Mediawiki 性能优化

来自森亮号航海见识 {SLboat Insight;}
跳转至: 导航搜索

更多研究

Mediawiki 性能优化/MySQL优化Mediawiki 性能优化/jobs时间Mediawiki 性能优化/各种怪异优化
Mediawiki 性能优化/缓存设置Mediawiki 性能优化/页面统计

发现

  • 关闭页面统计看起来会提高速度,但是看起来就不够酷了吧
$wgDisableCounters
  • 使用memcached看起来能得到不少的优化,但是和APC打架了吧 - memcached或许不需要太多内存呢
memcached 也能优化MySql啥的

For a heavy concurrent write load, InnoDB is essential. Set $wgAntiLockFlags = ALF_NO_LINK_LOCK | ALF_NO_BLOCK_LOCK; to reduce lock contention, at the expense of introducing occasional inconsistencies. Use memcached, not the default MySQL-based object cache.

  • HipHop看起来是个疯狂的工具-但是不能工作在mw

官方的一些优化建议

这里包含各种奇怪的工具
http://www.mediawiki.org/wiki/Manual:Performance_tuning

优化

优化缓存

开启php加速器APC

  • 设置主要缓存类型
$wgMainCacheType = CACHE_ACCEL; //默认无加速器CACHE_NONE,开启加速CACHE_ACCEL

开启APC测试

开启前

  • 测试域名本身
[root@li567-57 ~]# ab -kt 30 http://see.sl088.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking see.sl088.com (be patient)
Finished 99 requests


Server Software:        Apache/2.2.23
Server Hostname:        see.sl088.com
Server Port:            80

Document Path:          /
Document Length:        0 bytes

Concurrency Level:      1
Time taken for tests:   30.147 seconds
Complete requests:      99
Failed requests:        0
Write errors:           0
Non-2xx responses:      99
Keep-Alive requests:    0
Total transferred:      45837 bytes
HTML transferred:       0 bytes
Requests per second:    3.28 [#/sec] (mean)
Time per request:       304.513 [ms] (mean)
Time per request:       304.513 [ms] (mean, across all concurrent requests)
Transfer rate:          1.48 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   223  304  37.7    299     391
Waiting:      223  304  37.7    299     391
Total:        223  304  37.7    299     391

Percentage of the requests served within a certain time (ms)
  50%    298
  66%    314
  75%    329
  80%    339
  90%    364
  95%    375
  98%    389
  99%    391
 100%    391 (longest request)
  • 测试wiki子目录
[root@li567-57 ~]# ab -kt 30 http://see.sl088.com/wiki
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking see.sl088.com (be patient)
Finished 89 requests


Server Software:        Apache/2.2.23
Server Hostname:        see.sl088.com
Server Port:            80

Document Path:          /wiki
Document Length:        0 bytes

Concurrency Level:      1
Time taken for tests:   30.317 seconds
Complete requests:      89
Failed requests:        0
Write errors:           0
Non-2xx responses:      89
Keep-Alive requests:    0
Total transferred:      41207 bytes
HTML transferred:       0 bytes
Requests per second:    2.94 [#/sec] (mean)
Time per request:       340.645 [ms] (mean)
Time per request:       340.645 [ms] (mean, across all concurrent requests)
Transfer rate:          1.33 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   236  340 150.7    316    1413
Waiting:      235  340 150.7    316    1413
Total:        236  341 150.7    316    1413

Percentage of the requests served within a certain time (ms)
  50%    312
  66%    332
  75%    350
  80%    365
  90%    410
  95%    454
  98%   1073
  99%   1413
 100%   1413 (longest request)
  • 测试特定页
[root@li567-57 ~]# ab -kt 30 http://see.sl088.com/wiki/%E5%B8%AE%E5%8A%A9:%E7%B3%BB%E7%BB%9F:%E4%BC%98%E5%8C%96%E6%80%A7%E8%83%BD
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking see.sl088.com (be patient)
Finished 87 requests


Server Software:        Apache/2.2.23
Server Hostname:        see.sl088.com
Server Port:            80

Document Path:          /wiki/%E5%B8%AE%E5%8A%A9:%E7%B3%BB%E7%BB%9F:%E4%BC%98%E5%8C%96%E6%80%A7%E8%83%BD
Document Length:        35613 bytes

Concurrency Level:      1
Time taken for tests:   30.188 seconds
Complete requests:      87
Failed requests:        0
Write errors:           0
Keep-Alive requests:    0
Total transferred:      3132957 bytes
HTML transferred:       3098331 bytes
Requests per second:    2.88 [#/sec] (mean)
Time per request:       346.989 [ms] (mean)
Time per request:       346.989 [ms] (mean, across all concurrent requests)
Transfer rate:          101.35 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   258  347  76.9    331     754
Waiting:      247  334  75.9    319     730
Total:        258  347  76.9    331     754

Percentage of the requests served within a certain time (ms)
  50%    331
  66%    354
  75%    365
  80%    378
  90%    422
  95%    496
  98%    596
  99%    754
 100%    754 (longest request)

安装APC后

  • 测试单域名
[root@li567-57 ~]# ab -kt 30 http://see.sl088.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking see.sl088.com (be patient)
Finished 186 requests


Server Software:        Apache/2.2.23
Server Hostname:        see.sl088.com
Server Port:            80

Document Path:          /
Document Length:        0 bytes

Concurrency Level:      1
Time taken for tests:   30.147 seconds
Complete requests:      186
Failed requests:        0
Write errors:           0
Non-2xx responses:      186
Keep-Alive requests:    0
Total transferred:      86118 bytes
HTML transferred:       0 bytes
Requests per second:    6.17 [#/sec] (mean)
Time per request:       162.080 [ms] (mean)
Time per request:       162.080 [ms] (mean, across all concurrent requests)
Transfer rate:          2.79 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   127  162  36.2    158     545
Waiting:      127  162  36.2    158     545
Total:        128  162  36.2    158     546

Percentage of the requests served within a certain time (ms)
  50%    158
  66%    166
  75%    171
  80%    174
  90%    182
  95%    205
  98%    233
  99%    313
 100%    546 (longest request)

开启APC后

[root@li567-57 ~]# ab -kt 30 http://see.sl088.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking see.sl088.com (be patient)
Finished 184 requests


Server Software:        Apache/2.2.23
Server Hostname:        see.sl088.com
Server Port:            80

Document Path:          /
Document Length:        0 bytes

Concurrency Level:      1
Time taken for tests:   30.057 seconds
Complete requests:      184
Failed requests:        0
Write errors:           0
Non-2xx responses:      184
Keep-Alive requests:    0
Total transferred:      85192 bytes
HTML transferred:       0 bytes
Requests per second:    6.12 [#/sec] (mean)
Time per request:       163.353 [ms] (mean)
Time per request:       163.353 [ms] (mean, across all concurrent requests)
Transfer rate:          2.77 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   120  163  32.2    155     387
Waiting:      120  163  32.2    155     387
Total:        120  163  32.2    155     387

Percentage of the requests served within a certain time (ms)
  50%    155
  66%    163
  75%    169
  80%    171
  90%    190
  95%    205
  98%    262
  99%    331
 100%    387 (longest request)

见识

Linode Forum :: View topic - My Mediawiki site is very slow 沿途见识[1]

yeah, it doesn't rebuild the cache right away - it waits for the next visitor to view the page.

also, in 1.16 (i think, it didn't do that before) it also invalidates the cache if a template used by the page is edited and stuff like that. so it's really the best option for CPU and it guarantees your pages are almost always up to date - only exception i can think of is if you edit the skin template, but it's enough to truncate the cache table and/or delete all the files in the cache directory - which you should set outside of the public, world-viewable directory by the way.

MediaWiki Optimization Tutorial 沿途见识[2]

Check your MySQL slow log and see what slow queries you have for the MediaWiki database. Very often slow queries are caused by certain options such as the Page Counters. Here is an example MySQL slow query:
 
 Executed 37 min ago for 2 sec on Database --> YOUR_USER_wiki. 
UPDATE /* 127.0.0.1 */ `page` SET page_counter = page_counter + 1 WHERE page_id = 8 
 
In this case you will be forced to turn off the Page Counters. For this purpose add the following lineto your LocalSettings.php file:
$wgDisableCounters = true;
Your MySQL slow logs may vary. That's why try searching for disabling the functionality associated with them.
 


引用信息

以下是[Mediawiki 性能优化]所有用到的引用信息,向这些伟大的家伙致敬:
  1. ^ Linode Forum :: View topic - My Mediawiki site is very slow, 见识于2013-12-7 0:22
  2. ^ MediaWiki Optimization Tutorial, 见识于2013-4-17 19:54