ZeA*_*L0T 7 python nginx uwsgi
有可能以某种方式通过uwsgi的keepalive限制吗?如果不是,那么持久连接实现的最佳方式是什么.我正在使用NGiNX + uWSGI(Python),我希望客户端从服务器获得异步更新.
小智 6
如果您通过http收到请求,则UWSGI通过--http-keepalive选项支持保持活动。
/tmp$ cat app.py
def application(env, start_response):
content = b"Hello World"
start_response('200 OK', [
('Content-Type','text/html'),
('Content-Length', str(len(content))),
])
return [content]
Run Code Online (Sandbox Code Playgroud)
运行:
/tmp$ uwsgi --http=:8000 --http-keepalive -w app &> /dev/null
Run Code Online (Sandbox Code Playgroud)
我们可以connect通过strace 查看调用:
~$ strace -econnect wrk -d 10 -t 1 -c 1 http://127.0.0.1:8000
connect(3, {sa_family=AF_INET, sin_port=htons(8000), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
Running 10s test @ http://127.0.0.1:8000
1 threads and 1 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 92.32us 56.14us 2.81ms 97.20%
Req/Sec 11.10k 389.34 11.84k 68.32%
111505 requests in 10.10s, 7.98MB read
Requests/sec: 11040.50
Transfer/sec: 808.63KB
+++ exited with 0 +++
Run Code Online (Sandbox Code Playgroud)
看到?只有一个连接。
| 归档时间: |
|
| 查看次数: |
3786 次 |
| 最近记录: |