【发布时间】:2020-10-14 14:11:35
【问题描述】:
我已经使用 Flask over uWSGI 创建了一个 Web 服务。 Locust 测试产生了很多失败,这可能与响应非常大的事实有关。如何在每个响应最终失败之前为其设置超时。我的错误多种多样,但失败的是较大的响应。
7 GET /api/read/maa?length=0 HTTPError('500 Server Error: INTERNAL SERVER ERROR for url: http://iecdalpptalpp01.astrazeneca.net:5000/api/read/maa?length=0')
73 GET /api/read/maa?length=0 ConnectionError(ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')))
7 GET /api/read/maa?length=1 HTTPError('500 Server Error: INTERNAL SERVER ERROR for url: http://iecdalpptalpp01.astrazeneca.net:5000/api/read/maa?length=1')
53 GET /api/read/maa?length=1 ConnectionError(ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')))
3 GET /api/read/maa?length=2 HTTPError('500 Server Error: INTERNAL SERVER ERROR for url: http://iecdalpptalpp01.astrazeneca.net:5000/api/read/maa?length=2')
36 GET /api/read/maa?length=2 ConnectionError(ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')))
1 GET /api/read/maa?length=3 HTTPError('500 Server Error: INTERNAL SERVER ERROR for url: http://iecdalpptalpp01.astrazeneca.net:5000/api/read/maa?length=3')
36 GET /api/read/maa?length=3 ConnectionError(ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')))
34 GET /api/read/maa?length=4 ConnectionError(ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')))
33 GET /api/read/maa?length=5 ConnectionError(ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')))
23 GET /api/read/maa?length=6 ConnectionError(ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')))
24 GET /api/read/maa?length=7 ConnectionError(ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')))
13 GET /api/read/maa?length=8 ConnectionError(ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')))
5 GET /api/read/maa?length=9 ConnectionError(ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')))
24 GET /api/read/products/1093 ConnectionError(ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')))
29 GET /api/read/products/search?search=lynparza ConnectionError(ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')))
1 GET /api/read/products/search?search=lynparza HTTPError('500 Server Error: INTERNAL SERVER ERROR for url: http://iecdalpptalpp01.astrazeneca.net:5000/api/read/products/search?search=lynparza')
我的locustfile如下:
进口时间 from locust import HttpUser, task, between
class QuickstartUser(HttpUser):
wait_time = between(1, 2)
@task
def index_page(self):
self.client.get("/api/read/products/1093")
self.client.get("/api/read/products/search?search=lynparza")
@task(3)
def view_item(self):
for item_id in range(10):
self.client.get(f"/api/read/maa?length={item_id}")
time.sleep(0.5)
# def on_start(self):
# self.client.post("/login", json={"username": "foo", "password": "bar"})
【问题讨论】:
-
只是澄清一下:您是希望 locust 在服务器超时之前超时,还是希望服务器停止关闭连接?
-
我想增加 locust 响应的超时时间,但是如果我可以做些什么来阻止服务器关闭可能足够好的连接
-
这是关闭连接的服务器,所以我认为 locust 对此无能为力。也许检查您的服务器配置?
-
任何线索,我真的不是服务器人。我在 RHEL 7 上使用 uwsgi。我可以手动调用端点查看浏览器到端点并且没有任何问题。甚至没有使用 nginx。