I have a simple UWSGI app put behind a LB with the following .ini config
[uwsgi]
socket=0.0.0.0:5071
chdir = src/
wsgi-file = uwsgi.py
processes=2
threads=1
protocol=http
plugins=python
exit-on-reload=false
master=true
# Cleanup of temp files
vacuum = true
When all 2x1
threads are busy, the application keeps serving incoming connections by queueing them, waiting for a thread to free.
This is somehow an unwanted behavior in my case, as I would like UWSGI to return a 5xx status code which will allow me to not oversaturate the resources of a single distribution.
Client testing code
Attaching the test client code for the UWSGI application
proxy = {
'http':'http://localhost:5071'
}
@threaded
def f():
print('Sending request')
response = requests.get('http://dummy.site',proxies=proxy)
print(str(response.status_code )+ response.text)
for i in range(5):
f()
Test (1)
Adding listen = 2
to .ini and firing 3 requests simultaneously would just print:
*** uWSGI listen queue of socket "0.0.0.0:5071" (fd: 3) full !!! (3/2) ***
while the third connection seems to still be somehow accepted, queued and later executed instead of a 5xx
error being thrown.
Test (2)
Adding listen = 0
to .ini and firing 5 requests simultaneously would just execute two requests at a time. The full queue output is not showing anymore. Somehow, the requests are somewhere still queued and executed when threads get freed.
How can I block incoming connections to the UWSGI application when all threads are busy?