- 现象
在用 jmeter 对 Django 的服务进行压力测试的时候,当并发量上到一定的数量时(我压测的时候用了1000),服务器进程崩了,并报了错:
Traceback (most recent call last):
File "manage.py", line 21, in
File "manage.py", line 17, in main
File "/home/xiaojie/.conda/envs/xiaojie/lib/python3.7/site-packages/django/core/management/init.py", line 381, in execute_from_command_line
File "/home/xiaojie/.conda/envs/xiaojie/lib/python3.7/site-packages/django/core/management/init.py", line 375, in execute
File "/home/xiaojie/.conda/envs/xiaojie/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
File "/home/xiaojie/.conda/envs/xiaojie/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 60, in execute
File "/home/xiaojie/.conda/envs/xiaojie/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
File "/home/xiaojie/.conda/envs/xiaojie/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 95, in handle
File "/home/xiaojie/.conda/envs/xiaojie/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 102, in run
File "/home/xiaojie/.conda/envs/xiaojie/lib/python3.7/site-packages/django/utils/autoreload.py", line 585, in run_with_reloader
File "/home/xiaojie/.conda/envs/xiaojie/lib/python3.7/site-packages/django/utils/autoreload.py", line 570, in start_django
File "/home/xiaojie/.conda/envs/xiaojie/lib/python3.7/site-packages/django/utils/autoreload.py", line 288, in run
File "/home/xiaojie/.conda/envs/xiaojie/lib/python3.7/site-packages/django/utils/autoreload.py", line 294, in run_loop
File "/home/xiaojie/.conda/envs/xiaojie/lib/python3.7/site-packages/django/utils/autoreload.py", line 334, in tick
File "/home/xiaojie/.conda/envs/xiaojie/lib/python3.7/site-packages/django/utils/autoreload.py", line 350, in snapshot_files
File "/home/xiaojie/.conda/envs/xiaojie/lib/python3.7/site-packages/django/utils/autoreload.py", line 254, in watched_files
File "/home/xiaojie/.conda/envs/xiaojie/lib/python3.7/pathlib.py", line 1102, in glob
File "/home/xiaojie/.conda/envs/xiaojie/lib/python3.7/pathlib.py", line 562, in _select_from
File "/home/xiaojie/.conda/envs/xiaojie/lib/python3.7/pathlib.py", line 519, in _select_from
OSError: [Errno 24] Too many open files: '/home/xiaojie/.conda/envs/xiaojie/lib/python3.7/site-packages/django/contrib/admin/locale'
2. 问题
经过搜索查找,是系统层面上的报错,服务器的 Linux 系统同时打开的文件数有限制。
This is a system-level thing - you need to increase your ulimit for file handles (it's likely a small change in that patch version resulted in more file handles). I can't give instructions here for every OS, but if you search for ulimit file handles and your OS name you should find instructions on how to raise it.
3. 解决
更改系统配置
Check current limit
$ ulimit -n
256
Raise limit to 2048
$ ulimit -n 2048
标签:24,files,OSError,envs,py,xiaojie,File,home,line From: https://www.cnblogs.com/guowenrui/p/17262576.html