MySql数据库优化笔记(一)

针对新配置的Discuz论坛,通过调整my.ini设置,优化了数据库访问效率,显著提升了ab测试下的请求处理速度。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

关键词:MySQL  数据库 优化 访问慢 Discuz! Apache ab web压力测试

 

新配置了一个discuz论坛,数据库也是新安装,对my.ini没有进行过任何设置。

用ab测试。

ab -c 100 -n 1000 http://localhost/forum.php

 

测试结果如下:

Document Path:          /forum.php Document Length:        2118 bytes

Concurrency Level:      100 Time taken for tests:   238.752 seconds Complete requests:      1000 Failed requests:        96    (Connect: 0, Receive: 0, Length: 96, Exceptions: 0) Write errors:           0 Total transferred:      2188195 bytes HTML transferred:       1985211 bytes Requests per second:    4.19 [#/sec] (mean) Time per request:       23875.242 [ms] (mean) Time per request:       238.752 [ms] (mean, across all concurrent requests) Transfer rate:          8.95 [Kbytes/sec] received

Connection Times (ms)               min  mean[+/-sd] median   max Connect:        0    2   4.8      0      31 Processing:    31 12721 42814.3     62  218394 Waiting:       31 12721 42814.4     62  218394 Total:         31 12723 42814.4     62  218394

Percentage of the requests served within a certain time (ms)   50%     62   66%     78   75%     78   80%     94   90%  15881   95%  128251   98%  195681   99%  218207  100%  218394 (longest request)

 

开始进行优化:

1、将my.ini中设置
skip-name-resolve

注:论坛访问量几乎可以忽略。

测试结果如下:

 

Document Path:          /forum.php
Document Length:        23624 bytes

Concurrency Level:      100
Time taken for tests:   35.353 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      24247000 bytes
HTML transferred:       23624000 bytes
Requests per second:    28.29 [#/sec] (mean)
Time per request:       3535.251 [ms] (mean)
Time per request:       35.353 [ms] (mean, across all concurrent requests)
Transfer rate:          669.79 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    2   5.0      0      31
Processing:   296 3477 650.6   3479    5647
Waiting:      296 3470 649.9   3479    5632
Total:        296 3479 650.7   3479    5647

Percentage of the requests served within a certain time (ms)
  50%   3479
  66%   3592
  75%   3666
  80%   3713
  90%   3914
  95%   4867
  98%   5132
  99%   5429
 100%   5647 (longest request)



可以发现 速度明显上升。

 

未完待续。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值