[root@kvm5 ~]# yum install httpd-tools
kvm5.cyut.edu.tw 本機直接進行壓力測試,同時 1000 個連線做 20 次,測試結果前 50% 完成連線需要 5ms, 100% 完成連線需要 12ms。
[root@kvm5 ~]# ab -n 1000 -c 20 http://kvm5.deyu.wang/index.html
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking kvm5.deyu.wang (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: Apache/2.4.6
Server Hostname: kvm5.deyu.wang
Server Port: 80
Document Path: /index.html
Document Length: 7 bytes
Concurrency Level: 20
Time taken for tests: 0.238 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 265000 bytes
HTML transferred: 7000 bytes
Requests per second: 4208.83 [#/sec] (mean)
Time per request: 4.752 [ms] (mean)
Time per request: 0.238 [ms] (mean, across all concurrent requests)
Transfer rate: 1089.20 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 2
Processing: 3 4 0.9 4 11
Waiting: 3 4 0.9 4 11
Total: 3 5 1.0 5 12
Percentage of the requests served within a certain time (ms)
50% 5
66% 5
75% 5
80% 5
90% 5
95% 6
98% 8
99% 11
100% 12 (longest request)
mod_evasive 是一個預防 Apache 遭受 DDos 攻擊的模組,可以防止同一個 IP 對相同 URI 發出的大量請求,此模組 CentOS 7 預設並沒有,若使用 DYW Linux REPO 資料庫,可以直接以 yum 指令安裝。
[root@kvm5 ~]# yum install mod_evasive
mod_evasive 模組預設的設定。
[root@kvm5 ~]# vim /etc/httpd/conf.d/mod_evasive.conf
[root@kvm5 ~]# grep DOS /etc/httpd/conf.d/mod_evasive.conf
DOSHashTableSize 3097
DOSPageCount 2
DOSSiteCount 50
DOSPageInterval 1
DOSSiteInterval 1
DOSBlockingPeriod 10
#DOSEmailNotify you@yourdomain.com
#DOSSystemCommand "su - someuser -c '/sbin/... %s ...'"
#DOSLogDir "/var/lock/mod_evasive"
# Multiple DOSWhitelist commands may be used in the configuration.
#DOSWhitelist 127.0.0.1
#DOSWhitelist 192.168.0.*
httpd。
[root@kvm5 ~]# systemctl reload httpd.service