Nginx Static resource performance test

Source: Internet
Author: User
Basic Configuration
Hardware 1 Core CPU 1g memory
TOMCAT1 Port 8080
TOMCAT2 Port 1314
Nginx 1.10.2


The Nginx configuration is as follows:
I've got the compression transfer enabled, the load, and the Nginx cache (the static content in the Nginx memory)
#user nobody;


Worker_processes 1;

Events {worker_connections 1024;}
    HTTP {#扩展名与文件类型映射表 include mime.types; 

    Default_type Application/octet-stream;
    Sendfile on;
    Tcp_nopush on;
    Tcp_nodelay on;
    Keepalive_timeout 65;
  
    Types_hash_max_size 2048;
    #gzip compressed transport gzip on;  Gzip_min_length 1k;
    #最小1K gzip_buffers 64K;
    Gzip_http_version 1.1;
    Gzip_comp_level 6;
    Gzip_types text/plain application/x-javascript text/css application/xml application/javascript;

    Gzip_vary on;
    Proxy_cache_key ' $host: $server _port$request_uri ';
    Proxy_temp_file_write_size 64k; Proxy_temp_path/dev/shm/jielierp/proxy_temp_path; #这个位置 in memory Proxy_cache_path/dev/shm/jielierp/proxy_cache_path levels=1:2 keys_zone=cache_one:200m inactive=5d max_s
    ize=1g;

    Proxy_ignore_headers x-accel-expires Expires Cache-control Set-cookie;
    #配置代理参数 Proxy_redirect off;
    Proxy_set_header Host $host; Proxy_set_header X-real-ip $remote _Addr
    Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
    Client_max_body_size 10m;
    Client_body_buffer_size 128k;
    Proxy_connect_timeout 65;
    Proxy_send_timeout 65;
    Proxy_read_timeout 65;
    Proxy_buffer_size 4k;
    Proxy_buffers 4 32k;


    Proxy_busy_buffers_size 64k;
    #静态服务器组 upstream static.com {server 127.0.0.1:4808;
	} #动态服务器组 upstream dymic2.com {server 127.0.0.1:8080;
    Server 127.0.0.1:1314;
        } server{listen 80;

        server_name www.xdloveglt.cn; Location ~ (\.jsp) |
        (\.do) $ {proxy_pass http://dymic2.com; } location ~ (\.html) | (\.jpg) | (\.jpeg) | (\.png) | (\.js) |
            (\.CSS) $ {Proxy_cache cache_one;
            Proxy_cache_valid 304 302 5d;
            Proxy_cache_valid any 5d;
            Proxy_cache_key ' $host: $server _port$request_uri ';

	    Add_header X-cache ' $upstream _cache_status from $host ';
            Proxy_pass http://static.com; Expires 30d;
	#缓存30天} location/{#servlet或者别的没有后缀名的web款姐请求 also ok Proxy_pass http://dymic2.com;
         } server{Listen 4808;

	server_name www.xdloveglt.cn; 
        Location/{Root/usr/local/tomcat7_forzw/webapps; } location ~ (\.html) | (\.jpg) | (\.jpeg) | (\.png) | (\.js) | 
        (\.CSS) $ {root/usr/local/tomcat7_forzw/webapps;
 }
    }

}



My direct access
Http://www.xdloveglt.cn/PathTest/js/jquery-1.11.3.min.js
It's going to be through Nginx.
If it is:
Http://www.xdloveglt.cn:1314/PathTest/js/jquery-1.11.3.min.js
Http://www.xdloveglt.cn:8080/PathTest/js/jquery-1.11.3.min.js
That's going to go straight to Tomcat.


Use JMeter to test

The number of threads is 5,tamp-up period is 10s, the number of cycles is 3

First, direct access to Tomcat


Visit nginx


Average speed can increase about 10%

The feeling of ascension is not very big, I guess, should be my server configuration is too low, otherwise the increase of nginx works quantity, should be able to increase its processing of static resources faster


Resources

Http://www.cnblogs.com/wunaozai/p/5001742.html



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.