I've got an NGINX/flask/Docker server using: https://github.com/tiangolo/uwsgi-nginx-flask-docker and it works for running small and infrequent requests. But if I try a number of large requests that involve downloading ~5mb worth of data from amazon s3 for each (lets say, 10 at once). I get this error:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/local/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/local/lib/python2.7/site-packages/werkzeug/serving.py", line 659, in inner
srv.serve_forever()
File "/usr/local/lib/python2.7/site-packages/werkzeug/serving.py", line 499, in serve_forever
HTTPServer.serve_forever(self)
File "/usr/local/lib/python2.7/SocketServer.py", line 233, in serve_forever
self._handle_request_noblock()
File "/usr/local/lib/python2.7/SocketServer.py", line 292, in _handle_request_noblock
self.handle_error(request, client_address)
File "/usr/local/lib/python2.7/SocketServer.py", line 290, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/local/lib/python2.7/SocketServer.py", line 318, in process_request
self.finish_request(request, client_address)
File "/usr/local/lib/python2.7/SocketServer.py", line 331, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/lib/python2.7/SocketServer.py", line 652, in __init__
self.handle()
File "/usr/local/lib/python2.7/site-packages/werkzeug/serving.py", line 216, in handle
rv = BaseHTTPRequestHandler.handle(self)
File "/usr/local/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/usr/local/lib/python2.7/site-packages/werkzeug/serving.py", line 251, in handle_one_request
return self.run_wsgi()
File "/usr/local/lib/python2.7/site-packages/werkzeug/serving.py", line 193, in run_wsgi
execute(self.server.app)
File "/usr/local/lib/python2.7/site-packages/werkzeug/serving.py", line 184, in execute
write(data)
File "/usr/local/lib/python2.7/site-packages/werkzeug/serving.py", line 165, in write
self.wfile.write(data)
IOError: [Errno 32] Broken pipe
I've tried adding more processes and threads to nginx/wsgi. My uwsgi.ini looks like so:
[uwsgi]
module = main
callable = application
processes = 8
threads = 2
and my nginx.conf looks like this:
server {
location / {
try_files $uri @app;
}
location @app {
include uwsgi_params;
uwsgi_pass unix:///tmp/uwsgi.sock;
}
location /static {
alias /app/static;
}
}
Does anyone know what might be causing this?