比较Nginx和Tomcat处理静态资源能力
机器
192.168.64.135(安装Nginx)
192.168.64.140(安装Tomcat)
环境搭建
135机器
index.html页面
<!DOCTYPE html>
<html>
<head>
<title>Welcome to Nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1 style="color:blue">this is sb wrz 135 Nginx</h1>
<img src="/images/katong.jpeg" height="200" width="200" />
<img src="/images/shu.jpeg" height="200" width="200" />
</body>
</html>
image目录文件
katong.jpeg shu.jpeg (你换成你的图片文件)
配置文件
/usr/local/Nginx/conf/test/test.conf
server {
listen 85;
server_name 192.168.64.135;
location / {
root html;
try_files $uri $uri/ @java;
}
location @java {
proxy_pass http://192.168.64.140:8080;
}
}
主配置文件记得引用test.conf
include test/*.conf;
重启服务
./sbin/Nginx -s reload
浏览器测试
140机器
/usr/local/tomcat/tomcat8080/webapps/ROOT
下有文件index.jsp 目录images
index.jsp页面
<!DOCTYPE html>
<html>
<head>
<title>Welcome to Nginx!</title>
</head>
<body>
<h1 style="color:blue">this is sb wrz 140 tomcat</h1>
<img src="/images/katong.jpeg" height="200" width="200" />
<img src="/images/shu.jpeg" height="200" width="200" />
</body>
</html>
images目录文件
katong.jpeg shu.jpeg (你换成你的图片文件)
浏览器测试
压力测试
135 140安装yum install -y httpd-tools 用法等百度一下
135 140 都是静态资源 内容一样 测试Nginx和Tomcat处理静态资源能力
140 Tomcat测试
ab -n 10000 -c 200 http://192.168.64.140:8080/
135Nginx测试
结论
Nginx处理静态资源强于Tomcat处理静态资源能力
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。