我已经在uWSGI上使用Flask创建了一个Web服务。蝗虫测试产生了大量失败,可能与响应非常大有关。如何为每个响应设置超时,以免最终失败。我的错误多种多样,但较大的响应却失败了。
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')
我的蝗虫文件如下:
导入时间 从蝗虫导入HttpUser,任务之间
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"})
答案 0 :(得分:0)
经过很多混乱之后,我在Linux和Nginx中增加了打开文件的数量,将套接字队列从100增加到1024,并在创建SessionPool时使用了threaded = True的oracle数据库池-我逐渐变得合理结果。
sysctl -w net.core.somaxconn=1024
https://www.cyberciti.biz/faq/linux-unix-nginx-too-many-open-files/