Nginx做前端代理时缓存与否的性能差别
Nginx做前端代理,后端两台apache
upstream webservers {------------------定义在http段server 172.16.20.31 ;server 172.16.20.32 ; } proxy_cache_path /cache/webserver levels=1:2 keys_zone=web:100m max_size=1g inactive=12h;-----------------------------------------定义在http段 server {listen 80;server_name www.c.net; add_header X-Cache $upstream_cache_status;location / {proxy_pass http://webservers;proxy_set_header X-Real-IP $remote_addr;} }
未开启缓存的测试结果:
[root@node2 ~]# ab -c1000 -n10000 http://www.c.net/index.html 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 www.c.net (be patient) Completed 1000 requests Completed 2000 requests Completed 3000 requests Completed 4000 requests Completed 5000 requests Completed 6000 requests Completed 7000 requests Completed 8000 requests Completed 9000 requests Completed 10000 requests Finished 10000 requests Server Software: nginx/1.4.7 Server Hostname: www.c.net Server Port: 80 Document Path: /index.html Document Length: 192 bytes Concurrency Level: 1000 Time taken for tests: 6.589 seconds Complete requests: 10000 Failed requests: 9218(Connect: 0, Receive: 0, Length: 9218, Exceptions: 0) Write errors: 0 Non-2xx responses: 782 Total transferred: 2847868 bytes HTML transferred: 352940 bytes Requests per second: 1517.60 [#/sec] (mean) Time per request: 658.933 [ms] (mean) Time per request: 0.659 [ms] (mean, across all concurrent requests) Transfer rate: 422.06 [Kbytes/sec] received Connection Times (ms)min mean[+/-sd] median max Connect: 0 280 611.3 27 3066 Processing: 1 175 374.1 94 5439 Waiting: 1 168 374.3 89 5439 Total: 9 456 798.6 125 5834 Percentage of the requests served within a certain time (ms)50% 12566% 17075% 39380% 44090% 114195% 238798% 313799% 3768100% 5834 (longest request)
开启nginx缓存
upstream webservers {server 172.16.20.31 ;server 172.16.20.32 ; # server 127.0.0.1:80 backup;}proxy_cache_path /cache/webserver levels=1:2 keys_zone=web:100m max_size=1g inactive=12h;server {listen 80;server_name www.c.net;add_header X-Cache $upstream_cache_status;location / {proxy_pass http://webservers;proxy_set_header X-Real-IP $remote_addr;proxy_cache web;proxy_cache_valid 200 2h;proxy_cache_valid 301 302 10m;proxy_cache_valid any 1m;}}
Nginx开启缓存功能后的测试结果:
[root@node2 ~]# ab -c1000 -n10000 http://www.c.net/index.html 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 www.c.net (be patient) Completed 1000 requests Completed 2000 requests Completed 3000 requests Completed 4000 requests Completed 5000 requests Completed 6000 requests Completed 7000 requests Completed 8000 requests Completed 9000 requests Completed 10000 requests Finished 10000 requests Server Software: nginx/1.4.7 Server Hostname: www.c.net Server Port: 80 Document Path: /index.html Document Length: 0 bytes Concurrency Level: 1000 Time taken for tests: 2.944 seconds Complete requests: 10000 Failed requests: 9589(Connect: 0, Receive: 0, Length: 9589, Exceptions: 0) Write errors: 0 Total transferred: 2809577 bytes HTML transferred: 210958 bytes Requests per second: 3396.32 [#/sec] (mean) Time per request: 294.436 [ms] (mean) Time per request: 0.294 [ms] (mean, across all concurrent requests) Transfer rate: 931.86 [Kbytes/sec] received Connection Times (ms)min mean[+/-sd] median max Connect: 0 85 265.3 0 1005 Processing: 0 65 135.3 37 1475 Waiting: 0 60 135.6 36 1474 Total: 26 150 341.8 37 2478 Percentage of the requests served within a certain time (ms)50% 3766% 4075% 4580% 13190% 20695% 104098% 124499% 1653100% 2478 (longest request)
转载于:https://blog.51cto.com/xuqimin/1403117
Nginx做前端代理时缓存与否的性能差别相关推荐
- nginx做反向代理时出现302错误
现象:nginx在使用非80端口做反向代理时,浏览器访问发现返回302错误 详细现象如下: 浏览器请求登录页: 输入账号密码点击登录: 很明显登录后跳转的地址少了端口号. 原因:proxy.conf文 ...
- ceonts6.8 nginx做前端代理apache做后端服务架构配置
Apache 和 Nginx 说是当今最流行的两个 Web 服务器一点也不为过,Apache 用户基数大,稳定,兼容性高(比如jsp/php/cgi/python等等),但与 Ngnix 相比,Apa ...
- 使用Nginx做前端服务器时让Apache得到真实IP的方法
一:nginx.conf proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header ...
- Nginx做反向代理和负载均衡时“X-Forwarded-For”信息头的处理
转载自:https://blog.51cto.com/wjw7702/1150225 一.概述 如今利用nginx做反向代理和负载均衡的实例已经很多了,针对不同的应用场合,还有很多需要注意的地方,本文 ...
- 使用nginx做反代时遇到413 Request Entity Too Large的解决方法
使用nginx做反代时遇到413 Request Entity Too Large的解决方法 参考文章: (1)使用nginx做反代时遇到413 Request Entity Too Large的解决 ...
- 小程序nginx做反向代理_NGINX作为节点或Angular应用程序的反向代理
小程序nginx做反向代理 A reverse proxy is a server that retrieves resources for clients from one or more upst ...
- 利用 Nginx 做反向代理解决微信小程序业务域名限制问题
[查看原文] https://fyh.me/2018/07/12/nginx-docker-miniprogram/ 最近做了一个世界杯比赛日程的小程序,只有查看日程的功能,所以很快就发布上线了.后边 ...
- nginx 发布前端资源的缓存方案
nginx 发布前端资源的缓存方案 前言 对于前端开发者来说,最头疼的事情莫过于.当你兴冲冲的给项目打包以后,上传到 nginx 等静态资源服务器发布以后,自己本地验证没问题,以为万事大吉,结果测试人 ...
- nginx做正向代理
Nginx常用来做反向代理,但是作为正向代理大家有没有试过呢? Nginx配置如下: server{ resolver x.x.x.x; listen 82; ...
最新文章
- 【ArcGIS风暴】缓冲区分析、叠置分析综合实验案例:购房区域的选择
- linux发展前景2018,2018 年 Linux 的 8 个发展预测
- sudo echo x **.** 时 base: : Permission denied
- 给datalist加自动编号(解决博客的第XX楼)
- c语言程序设计教程课后选择题答案,C语言程序设计教程课后习题包括答案.docx...
- android某个界面横屏,iOS强制某个界面横屏的方法
- 惠普1020打印机查看已打印页数
- BS和CS的区别有哪些:
- WINDOWS XP 桌面主题的安装制作
- iOS(swift): Core ML的使用
- 大学生活这样过,等着 Offer 飞来找 | 程序员有话说
- windows 20003 扩展安装后不成功的原因
- 【linux 释放内存】linux释放内存骚操作
- python输入十个数字的成语_【一到十十个数字开头的成语】作业帮
- [web效果实现-3] 拼音排序通讯录实现
- 移动安全常用技术相关术语总结
- 深信服上网行为管理AC识别不到Youtube、Outlook邮箱流量的解决方法
- 在Windows中安装一些python的第三方库
- 四个视频营销策略,让你火过傅园慧,Papi酱
- 施耐德电气推出适用于边缘计算的微型数据中心机柜