安装nginx
apt-get install -y nginx
配置 nginx
查看自己服务器ip
curl ip.sb
vim /etc/nginx/conf.d/cdn.conf
server {
listen 80;
server_name 127.0.0.1;#指定自己机器ip
charset utf-8,gbk;
location / {
proxy_set_header Accept-Encoding "";
client_max_body_size 50m;
proxy_pass http://file.test.com;#调转的服务域名或者ip加端口
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache_valid 200 304 30m;
proxy_cache_valid 301 24h;
proxy_cache_valid 500 502 503 504 0s;
proxy_cache_valid any 1s;
proxy_cache_min_uses 1;
expires 12h;
}
}
重启 nginx
service nginx restart
ab 测试
工具安装
sudo apt-get install apache2-utils
环境
带宽统一 80m
反代机器 1 核 1g
生产压测
测试命令
ab -n 100 -c 6 -p test.txt -T "multipart/form-data; boundary=----WebKitFormBoundaryAFQSEaLDUcBnvQtT" http://file.test.com/v1/upload
测试结果
This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking file.test.com (be patient).....done
Server Software: cloudflare
Server Hostname: file.test.com
Server Port: 80
Document Path: /v1/upload
Document Length: 56 bytes
Concurrency Level: 6
Time taken for tests: 8.143 seconds
Complete requests: 100
Failed requests: 0
Total transferred: 60312 bytes
Total body sent: 99454248
HTML transferred: 5600 bytes
Requests per second: 12.28 [#/sec] (mean)
Time per request: 488.599 [ms] (mean)
Time per request: 81.433 [ms] (mean, across all concurrent requests)
Transfer rate: 7.23 [Kbytes/sec] received
11926.75 kb/s sent
11933.99 kb/s total
Connection Times (ms)
min mean[+/-sd] median max
Connect: 1 11 100.6 1 1007
Processing: 43 460 360.8 381 1762
Waiting: 14 150 223.8 62 1758
Total: 44 471 379.6 382 1763
Percentage of the requests served within a certain time (ms)
50% 382
66% 565
75% 722
80% 840
90% 988
95% 1232
98% 1655
99% 1763
100% 1763 (longest request)
测试命令文件
文件目录 vim /tmp/test.txt
内容自己填充 图片则转成bese64文本放进文件即可,下面是个示例
文件大小975 kb
------WebKitFormBoundaryAFQSEaLDUcBnvQtT
Content-Disposition: form-data; name="appId";appId="upload";
/tmp/test.txt
------WebKitFormBoundaryAFQSEaLDUcBnvQtT
Content-Disposition: form-data; name="file";file="/tmp/test.txt";
Content-Type:multipart/form-data
啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊
233333333333333333333333333331
231阿萨德撒啊啊啊啊啊啊啊啊啊
1打算
啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊
233333333333333333333333333331
231阿萨德撒啊啊啊啊啊啊啊啊啊
1打算
------WebKitFormBoundaryAFQSEaLDUcBnvQtT----
注意你的配置代码和资源需在开头结尾中间
------WebKitFormBoundaryAFQSEaLDUcBnvQtT
------WebKitFormBoundaryAFQSEaLDUcBnvQtT----
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)