Openresty安装

一、依赖环境安装(如果已安装可跳过)

yum install -y gcc openssl-devel readline-devel pcre-devel perl

二、 openresty安装

下载地址 http://openresty.org/cn/download.html

curl -R -O https://openresty.org/download/openresty-1.13.6.1.tar.gz
tar xzvf openresty-1.13.6.1.tar.gz 
./configure --user=root --group=root --prefix=/usr/local/openresty-1.13.6.1 --with-luajit --without-http_redis2_module --with-http_iconv_module --with-http_ssl_module --with-http_stub_status_module --with-pcre --with-http_realip_module
gmake && gmake install

三、HelloWorld

$ cat /usr/local/openresty/nginx/conf/nginx.conf
worker_processes  1;
error_log logs/error.log info;

events {
    worker_connections 1024;
}

http {
    server {
        listen 81;

        location / {
            content_by_lua 'ngx.say("hello world.")';
        }
    }
}

-- 启动nginx
$ /usr/local/openresty/nginx/sbin/nginx

-- 检查nginx
$ curl http://127.0.0.1:81/
hello world.

四、性能测试

-- 安装压力测试工具
$ yum install httpd-tools

-- 测试
$ ab -c10 -n50000 http://localhost:8003/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 5000 requests
Completed 10000 requests
Completed 15000 requests
Completed 20000 requests
Completed 25000 requests
Completed 30000 requests
Completed 35000 requests
Completed 40000 requests
Completed 45000 requests
Completed 50000 requests
Finished 50000 requests


Server Software:        openresty/1.13.6.1
Server Hostname:        127.0.0.1
Server Port:            81

Document Path:          /
Document Length:        13 bytes

Concurrency Level:      10
Time taken for tests:   4.270 seconds
Complete requests:      50000
Failed requests:        0
Write errors:           0
Total transferred:      8800000 bytes
HTML transferred:       650000 bytes
Requests per second:    11710.28 [#/sec] (mean)
Time per request:       0.854 [ms] (mean)
Time per request:       0.085 [ms] (mean, across all concurrent requests)
Transfer rate:          2012.70 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.4      0       8
Processing:     0    1   1.0      0      15
Waiting:        0    0   0.9      0      15
Total:          0    1   1.1      0      15
WARNING: The median and mean for the processing time are not within a normal deviation
        These results are probably not that reliable.

Percentage of the requests served within a certain time (ms)
  50%      0
  66%      1
  75%      1
  80%      1
  90%      1
  95%      3
  98%      5
  99%      6
 100%     15 (longest request)

你可能感兴趣的:(Openresty)