uwsgi在高压下徘徊

时间:2015-07-22 14:00:26

标签: python mod-wsgi wsgi uwsgi gunicorn

我正在尝试uwsgi:

为此,我创建了一个python虚拟环境并在其中安装了uwsgi。

我从文档中创建了foobar.py示例文件:

def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return [b"Hello World"]

并开始使用文档中提出的uwsgi:

uwsgi --http :9090 --wsgi-file foobar.py --master --processes 4 --threads 2 --logto /tmp/uwsgi.log

然后我使用'ab'制作一个小基准,在7000次请求之后,工作台挂起,没有理由(日志中没有消息):

$ ab -n 10000 -c 100 http://127.0.0.1:9090/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
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 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
^C      <-----------------------needed to break the bench here.

Server Software:
Server Hostname:        127.0.0.1
Server Port:            9090

Document Path:          /
Document Length:        11 bytes

Concurrency Level:      100
Time taken for tests:   18.275 seconds
Complete requests:      7208
Failed requests:        0
Write errors:           0
Total transferred:      396440 bytes
HTML transferred:       79288 bytes
Requests per second:    394.41 [#/sec] (mean)
Time per request:       253.544 [ms] (mean)
Time per request:       2.535 [ms] (mean, across all concurrent requests)
Transfer rate:          21.18 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    3   0.5      3       6
Processing:     0    8   1.3      8      13
Waiting:        0    8   1.4      8      13
Total:          0   11   1.7     10      16

Percentage of the requests served within a certain time (ms)
  50%     10
  66%     11
  75%     12
  80%     13
  90%     13
  95%     14
  98%     15
  99%     15
 100%     16 (longest request)

如果我重做测试,挂起前只有3000个请求通过。 我尝试使用较少的并发(10甚至1),但它仍然发生。 我在OS / X 10.8和ubuntu 12.04上遇到过这种行为。 我确实和gunicorn有同样的行为,但它的作用就像是一个带有apache / mod_wsgi的魅力。

你能告诉我如何在高压下不让uwsgi挂起来吗?

0 个答案:

没有答案