python - Locust 负载测试给了我 ChunkedEncodingError
问题描述
我正在负载测试我的 django gunicorn nginx 和 postgresql 应用程序。在大约 1500 个并发用户之后,我的 locust failed 选项卡中出现以下错误:
1 GET / ChunkedEncodingError(ProtocolError('Connection broken: IncompleteRead(2773 bytes read, 7467 more expected)', IncompleteRead(2773 bytes read, 7467 more expected)))
我检查了我所有的访问和错误日志(nginx 访问和错误日志、gunicorn 日志、syslog、postgresql 日志),但我找不到与上述错误相关的任何内容。
是蝗虫错误吗?是超时错误吗?我似乎找不到出了什么问题。
这是我的蝗虫文件:
from locust import HttpLocust, TaskSet, task, between
from requests.auth import HTTPBasicAuth
class UserBehavior(TaskSet):
@task(4)
def index(self):
self.client.get("", auth=("user", "pass"))
@task(4)
def program(self):
self.client.get("page1/", auth=("user", "pass"))
@task(1)
def artist(self):
self.client.get("page1/sub-page/", auth=("user", "pass"))
@task(2)
def tickets(self):
self.client.get("page2/", auth=("user", "pass"))
class WebsiteUser(HttpLocust):
task_set = UserBehavior
wait_time = between(7, 30)
如您所见,我正在使用基本身份验证来访问该页面。我不知道在很多请求之后这是否真的会导致错误。
什么可能导致此错误?提前致谢!
解决方案
有人(可能是服务器)似乎正在关闭连接,而 locust 并不能告诉你更多。
SO上有许多关于此异常的其他票证(关于一般的请求库,而不是专门针对蝗虫),也许其中一个可能会有所帮助。
您也可以尝试新的 FastHttpLocust,它使用不同的请求库(您很可能仍然会收到错误,但可能会显示不同的内容)
在服务器端检查您的 ulimits 设置可能是值得的。
推荐阅读
- php - 如何通过 php 使用 sendgrid 正确发送电子邮件
- c# - C# Windows 窗体应用程序 ListView:如何强制 ListView 不更新?
- php - 无法将值添加到关联数组 php
- azure-devops - 当我包含代码覆盖率时,无法获得 Azure DevOps Release Pipelines
- c - 在 gcc 中编译 c 时收到有关强制转换“从指针到不同大小的整数”的警告
- java - 无效标志:将 java 包升级到 1.8.0_211 后的 -jar
- python - 如何在 Subprocess.run 命令中使用 for 循环
- python-3.x - 如何让我的计算机识别用 python3 编写的代码?
- swift - 如何在 viewDidLoad 中调用 UIButton 的扩展
- routes - 默认控制器上的更改导致 404 Page Not Found