Analysis on head pressure measurement of Nginx added CONTENT-MD5

Source: Internet
Author: User

This article reproduced must indicate the original address, please respect the author's labor results! 1.1

Webbench is a well-known website stress testing tool that was developed by Lionbridge Inc. (http://www.lionbridge.com). Webbench can test the performance of different services on the same hardware, as well as the health of the same service on different hardware. The standard test of Webbench can show us two things about the server: the corresponding requests per second and the amount of data transferred per second. Webbench can not only have the ability to test the static pages, but also the ability to test dynamic pages (asp,php,java,cgi). And he supports static or dynamic performance testing of secure websites that contain SSL, such as e-commerce sites. Webbench can simulate up to 30,000 concurrent connections to test the load capacity of the Web site.

1.2 Installation

#wget http://home.tiscali.cz/~cz210552/webbench.html/webbench-1.5.tar.gz

#tar ZXVF webbench-1.5.tar.gz

#cd webbench-1.5

#make

#make Install

1.3 Webbench Use

Webbench-c 1000-t http://test.my4399.com/download/md5.html

Webbench-c Concurrent number-T run test time URL

2 nginx Add FILE-MD5 Module 2.1 Introduction

The HTTP protocol has a new CONTENT-MD5 HTTP header, but Nginx does not support this feature, and the official has made it clear that this feature will not be added. Because every request needs to read the entire file to calculate the MD5 value, the performance-known nginx is absolutely unwilling to do something contrary to the purpose of the software. However, in some applications, it is necessary to verify the correctness of the file, some people download the current file, and then calculate the MD5 value to correct the current file. Not only does wasting bandwidth resources also waste a lot of time. There is a need for solutions, netizens developed the FILE-MD5 module.

2.2 Download FILE-MD5 Module

#cd/USR/LOCAL/SRC

# wget Https://github.com/cfsego/file-md5/archive/master.zip-O File-md5-master.zip

# Unzip File-md5-master.zip

2.3 Downloads nginx-1.4.2

# wget http://nginx.org/download/nginx-1.4.2.tar.gz

# TAR-XZF Nginx-1.4.2.tar.gz

# CD nginx-1.4.2

2.4 Downloads Pcre-8.38.tar.gz

Tar xvf pcre-8.38.tar.gz-c/usr/local/src/

2.5 Compiling the FILE-MD5 module

#./configure--prefix=/usr/local/nginx-1.4.2--add-module=. /file-md5-master--with-pcre=. /pcre-8.38/--with-openssl=/usr/include

#make

#make Install

2.6 Configuring the Vhost file

server {

Listen 80;

server_name test.my4399.com;

Root/data/web/test;

# for Add Content-md5 to HTTP header

Location ~/download

{

Add_header content-md5 $file _md5;

}

}

2.7 Start Nginx

#cd/usr/local/nginx-1.4.2

#./sbin/nginx-c conf/nginx.conf

3 nginx Add Perl Module 3.1 prepare Perl module related files

#cd/usr/local/nginx-1.4.2/

Store the following contentmd5.pm files under/usr/local/nginx-1.4.2/perl/lib/, and the file name must be contentmd5.pm

# nginx Embedded Perl module for adding a content-md5 HTTP header

#

# This Perl module, would output an MD5 of a requested file using the

# CONTENT-MD5 HTTP header, by either pulling it from a file of the

# same name with. MD5 appended to the end, if it exists, or would

# Calculate the MD5 hex hash on the fly

#

# Author:matt Martz <[email protected]>

# link:https://gist.github.com/1870822#file_content_md5.pm

# License:http://www.nginx.org/license

Package ContentMD5;

Use Nginx;

Use DIGEST::MD5;

Sub handler {

my $r = shift;

My $filename = $r->filename;

return declined Unless-f $filename;

My $content _length =-S $filename;

My $MD 5;

if (-F "$filename. MD5") {

Open (Md5file, "$filename. MD5") or return declined;

$MD 5 = <MD5FILE>;

Close (Md5file);

$MD 5 =~ s/^\s+//;

$MD 5 =~ s/\s+$//;

$MD 5 =~ s/\. *//;

} else {

Open (FILE, $filename) or return declined;

My $ctx = digest::md5->new;

$ctx->addfile (*file);

$MD 5 = $ctx->hexdigest;

Close (FILE);

}

$r->header_out ("Content-md5", $MD 5) unless! $MD 5;

return declined;

}

1;

3.2 Compiling

#cd/usr/local/src/nginx-1.4.2

#./configure--prefix=/usr/local/nginx-1.4.2--with-pcre=. /pcre-8.38/--with-openssl=/usr/include--with-http_stub_status_module--with-http_perl_module--with-http_ Addition_module--with-http_realip_module--with-http_sub_module

#make

#make Install

3.3 Edit nginx.conf

Add in HTTP Field

Perl_modules Perl/lib;

Perl_require contentmd5.pm;

3.4 Edit Vhost

server {

Listen 80;

server_name test.my4399.com;

Root/data/web/test;

Location/{

Root/data/web/test;

Index index.html;

}

Location/download {

Perl Contentmd5::handler;

}

}

3.5 Start Nginx

#chown Www.www/usr/local/nginx-1.4.2-R

#cd/usr/local/nginx-1.4.2

#./sbin/nginx-c conf/nginx.conf

4 test Results 4.1 using FILE-MD5 module

Use the links below and use Chrome's F12 access at the same time to see the return times.

Time Webbench-c 2700-t http://test.my4399.com/download/md5.html

4.2 Using the Perl module

Use the links below and use Chrome's F12 access at the same time to see the return times.

Time Webbench-c 2700-t http://test.my4399.com/download/md5_perl.html

5 References

Http://www.ttlsa.com/nginx/nginx-modules-ngx_file_md5

https://gist.github.com/sivel/1870822

Nginx Add content-md5 head pressure test analysis

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.