我在asyncio
项目中安装了Ioloop
tornado
,它在单个请求中运行时没有问题,但是当我进行服务器压力测试时:
ab -n 10000 -c 4000 -p '/home/mwh/ad_tornado/for_test/task.json' -T 'application/x-www-form-urlencoded' '192.168.1.170/hwSdk/tsk/get_t_k.json'
发生了错误:
[E 161216 10:32:22 base_events:1090] Exception in callback BaseAsyncIOLoop._handle_events(11, 1)
handle: <Handle BaseAsyncIOLoop._handle_events(11, 1)>
Traceback (most recent call last):
File "/usr/local/lib/python3.4/asyncio/events.py", line 125, in _run
File "/home/mwh/virtualenv_mwh/lib/python3.4/site-packages/tornado/platform/asyncio.py", line 114, in _handle_events
File "/home/mwh/virtualenv_mwh/lib/python3.4/site-packages/tornado/stack_context.py", line 275, in null_wrapper
File "/home/mwh/virtualenv_mwh/lib/python3.4/site-packages/tornado/netutil.py", line 260, in accept_handler
File "/usr/local/lib/python3.4/socket.py", line 187, in accept
OSError: [Errno 24] Too many open files
在龙卷风中使用asynico ioloop会降低性能吗?
答案 0 :(得分:2)
您正在尝试运行4000
个并行请求,这意味着4000
同时打开了套接字。
但通常系统限制默认只允许1024个打开的文件(尝试ulimit -a
)。
您可以通过ulimit -n 4096
调用覆盖限制。