is this ab test for nginx and tornado normal ?

138 views
Skip to first unread message

panfei

unread,
May 31, 2012, 2:50:44 AM5/31/12
to python-...@googlegroups.com
server : 16cores CPU + 16GB mem  Dell server

I also want to know : how to deploy Tornado with nginx as the load balance server, thanks 

Nginx (the default welcome page):

[root@report ~]# ab -c 1000 -n 10000 report:8247/          
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking report (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Finished 10000 requests


Server Software:        nginx/1.0.14
Server Hostname:        report
Server Port:            8247

Document Path:          /
Document Length:        151 bytes

Concurrency Level:      1000
Time taken for tests:   0.950062 seconds
Complete requests:      10000
Failed requests:        867
   (Connect: 0, Length: 867, Exceptions: 0)
Write errors:           0
Non-2xx responses:      867
Total transferred:      3613931 bytes
HTML transferred:       1546414 bytes
Requests per second:    10525.63 [#/sec] (mean)
Time per request:       95.006 [ms] (mean)
Time per request:       0.095 [ms] (mean, across all concurrent requests)
Transfer rate:          3714.49 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    2   8.6      0      48
Processing:    10   13   8.9     11     222
Waiting:        7   12   7.9     10     222
Total:         10   15  16.0     11     224

Percentage of the requests served within a certain time (ms)
  50%     11
  66%     11
  75%     11
  80%     11
  90%     28
  95%     57
  98%     75
  99%     75
 100%    224 (longest request)



Tornado (The hello world app):

[root@report ~]# ab -c 1000 -n 10000 report:8888/ 
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking report (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Finished 10000 requests


Server Software:        TornadoServer/2.2.1
Server Hostname:        report
Server Port:            8888

Document Path:          /
Document Length:        12 bytes

Concurrency Level:      1000
Time taken for tests:   7.401306 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      1700000 bytes
HTML transferred:       120000 bytes
Requests per second:    1351.11 [#/sec] (mean)
Time per request:       740.131 [ms] (mean)
Time per request:       0.740 [ms] (mean, across all concurrent requests)
Transfer rate:          224.28 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0  133 616.5      0    3001
Processing:    13  102 197.7     62    2006
Waiting:       12  102 197.7     62    2006
Total:         24  235 666.6     65    4942

Percentage of the requests served within a certain time (ms)
  50%     65
  66%     73
  75%     78
  80%     82
  90%    195
  95%   1603
  98%   3064
  99%   3072
 100%   4942 (longest request)
--
不学习,不知道

youenn boussard

unread,
May 31, 2012, 5:11:14 AM5/31/12
to python-...@googlegroups.com
On Thu, May 31, 2012 at 8:50 AM, panfei <cnw...@gmail.com> wrote:
server : 16cores CPU + 16GB mem  Dell server

I also want to know : how to deploy Tornado with nginx as the load balance server, thanks 



Exemple (nginx.conf):
 
http {
    # Enumerate all the Tornado servers here
    upstream frontends {
        server 127.0.0.1:8000;
        server 127.0.0.1:8001;
        server 127.0.0.1:8002;
        server 127.0.0.1:8003;
    }
 
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    access_log /var/log/nginx/access.log;

    keepalive_timeout 65;
    proxy_read_timeout 200;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    gzip on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    gzip_min_length 1000;
    gzip_proxied any;
    gzip_types text/plain text/html text/css text/xml
               application/x-javascript application/xml
               application/atom+xml text/javascript;

    # Only retry if there was a communication error, not a timeout
    # on the Tornado server (to avoid propagating "queries of death"
    # to all frontends)
    proxy_next_upstream error;

    server {
        listen 80;
        # Allow file uploads
        client_max_body_size 2G;

        location ^~ /static/ {
            root /var/www;
            if ($query_string) {
                expires max;
            }
        }
        location = /favicon.ico {
            rewrite (.*) /static/favicon.ico;
        }
        location = /robots.txt {
            rewrite (.*) /static/robots.txt;
        }

        location / {
            proxy_pass_header Server;
            proxy_set_header Host $http_host;
            proxy_redirect off;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Scheme $scheme;
            proxy_pass http://frontends;
        }
    }
}


+ conf of supervisor for deployment 

[unix_http_server]
file=/tmp/supervisor.sock
 
[supervisord]
logfile=<path_log>/supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=warn
pidfile=<home>/supervisord.pid
nodaemon=false
minfds=1024
minprocs=200
user=allany
childlogdir=/tmp/logs
environment=USER=<user>,HOME=<home>

[supervisorctl]
serverurl = unix:///tmp/supervisor.sock

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
 
[group:myapp]
programs=tornado-8000,tornado-8001,tornado-8002,tornado-8003
 
[program:tornado-8000]
command=<path tornado command> -port=8000
directory=<directory>
autorestart=true
redirect_stderr=true
stdout_logfile=<path-to-log>/tornado-8000.log
stdout_logfile_maxbytes=500MB
stdout_logfile_backups=50
stdout_capture_maxbytes=1MB
stdout_events_enabled=false
loglevel=warn


[program:tornado-8001]
....


for start supervisor :

>>> supervisord

for reload supervisor :

>>> supervisorctl reload

Regards Youenn.

panfei

unread,
May 31, 2012, 5:30:38 AM5/31/12
to python-...@googlegroups.com
thanks very much !

2012/5/31 youenn boussard <y.bou...@free.fr>



--
不学习,不知道

David Koblas

unread,
May 31, 2012, 8:37:03 AM5/31/12
to python-...@googlegroups.com, youenn boussard
You might consider a supervisor config that's self describing like:
[program:tornado]
process_name = tornado-%(process_num)s
command=<command> --port=%(process_num)s

# Increase numprocs to run multiple processes on different ports.
numprocs = 4
numprocs_start = 8000
You can then just change 'numprocs=8' if you want 8 processes, also you no longer need the 'group' supervisor configuration.

--koblas

youenn boussard

unread,
May 31, 2012, 8:41:11 AM5/31/12
to python-...@googlegroups.com
On Thu, May 31, 2012 at 2:37 PM, David Koblas <da...@koblas.com> wrote:
You might consider a supervisor config that's self describing like:
[program:tornado]
process_name = tornado-%(process_num)s
command=<command> --port=%(process_num)s

# Increase numprocs to run multiple processes on different ports.
numprocs = 4
numprocs_start = 8000
cool! 
Reply all
Reply to author
Forward
0 new messages