a year ago
I've deployed a flask server and it works totally fine if I test it on a dev Vercel deployment, but as soon as I switch the prod backend to the railway flask server and start getting high traffic, I get this weird error over and over. Definitely a traffic thing because it even works for the first few seconds that I deploy, but quickyl get CORS error, presumably because the server can't send back headers.
2024-02-25 18:05:24 +0000] [11] [ERROR] Socket error processing request.
Traceback (most recent call last):
File "/opt/venv/lib/python3.8/site-packages/gunicorn/workers/sync.py", line 133, in handle
req = next(parser)
File "/opt/venv/lib/python3.8/site-packages/gunicorn/http/parser.py", line 41, in __next__
self.mesg = self.mesg_class(self.cfg, self.unreader, self.req_count)
File "/opt/venv/lib/python3.8/site-packages/gunicorn/http/message.py", line 186, in __init__
super().__init__(cfg, unreader)
File "/opt/venv/lib/python3.8/site-packages/gunicorn/http/message.py", line 53, in __init__
unused = self.parse(self.unreader)
File "/opt/venv/lib/python3.8/site-packages/gunicorn/http/message.py", line 235, in parse
self.headers = self.parse_headers(data[:idx])
File "/opt/venv/lib/python3.8/site-packages/gunicorn/http/message.py", line 73, in parse_headers
remote_addr = self.unreader.sock.getpeername()
OSError: [Errno 107] Transport endpoint is not connected
0 Replies
a year ago
have you tried increasing the workers and threads?
a year ago
have a read of gunicorns docs, they provide flags to set the number of workers and threads gunicorn will use
a year ago
i would try with a single replica but with more workers and threads
railway runs the flask server for me though, would you suggest switching to a docker container so I can actually set these parameters?
a year ago
railway does not run the server for you, you are in full control of whats ran at all times
a year ago
most python users have their start commands defined in a Procfile
a year ago
no problem!