Nginx性能优化(五)

比较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处理静态资源能力

相关文章

一 、安装solr 环境说明:centos 7.3,solr 6.6,zookeeper3...
tomcat 日志说明 配置文件server.xml 默认日志格式为 推荐使...
在实际生产环境中,tomcat的 catalina.out日志默认是不切割的...
简介: SSL 协议的3个特性: 保密:通过SSL链接传输的数据是...
遵循Java Servlet 规范第4节中的建议 ,Apache Tomcat实现了...