简体   繁体   中英

Locust failures - how to increase the timeout

I have created a web service using Flask over uWSGI. Locust testing is generating a lot of failures which are possibly related to the fact that the responses are quite large. How do I set a timeout for each response before it ends up failing. My errors are varied, but it is the larger responses which are failing.

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')

My locustfile is as below:

import time 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"})

After a lot of messing around, I increased the number of open files in Linux and nginx, increased the socket queue from 100 to 1024, and used oracle database pooling with threaded=True when creating the SessionPool - and I am getting reasonable results now.

sysctl -w net.core.somaxconn=1024

https://www.cyberciti.biz/faq/linux-unix-nginx-too-many-open-files/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM