0
votes

I created an python api on openshift online with python image. If you request all the data, it takes more than 30 seconds to respond. The server gives a 504 gateway timeout http response. How do you configure the length a response can take? > I created an annotation on the route, this seems to set proxy timeout.

haproxy.router.openshift.io/timeout: 600s

Problem remains, I now got logging. It looks like the message comes from mod_wsgi.

I want to try alter the configuration of the httpd (mod_wsgi-express process) from request-timeout 60 to request-timeout 600. Where doe you configure this. I am using base image https://github.com/sclorg/s2i-python-container/tree/master/2.7

Logging:

Timeout when reading response headers from daemon process  'localhost:8080':/tmp/mod_wsgi-localhost:8080:1000430000/htdocs

Does someone know how to fix this error on openshift online

1
What sort of work are you doing that requests take that long? It sounds like you should not be doing the processing in the context of a web request, but offloading the processing to a task queueing system such as Celery. By allow such long running requests, if you get many of these at the same time, you will block up the whole web server as you will run out of capacity. - Graham Dumpleton
I agree, that could be a problem in the future. For now it works because the request is made max 10 times a day, but this can increase in the future. It is an api request with a lot of work serverside to generate the data. What would your solution be? Offload the work to celery and send the response when finished? - jeew
Celery would be overkill if so infrequent. But usually you would offload to background and return acknowledgement that queued. Then have client poll somehow to check if complete. If that works for you currently go with it. The only concern would have is that those time outs then apply to all requests handled, which means for the short requests you loose ability to mod_wsgi to recover if they start getting stuck. One can start using multiple daemon process groups and split traffic as explained in blog.dscpl.com.au/2014/02/… - Graham Dumpleton
Using multiple daemon processes can be something look at later if is an issue. Can then explain how to do that with mod_wsgi-express. - Graham Dumpleton
Great, a daemon process for this endpoint sounds like a solution, I would lik to know how this works, will read the link you send me. I am thinking also on another solution. The data changes one time per day in the database, I could also generate all the possible data, save it in a file. And let the api work with the file. What would you prefer. - jeew

1 Answers

1
votes

Next to alter timeout of haproxy of the route of my app

haproxy.router.openshift.io/timeout: 600s

I altered the request-timeout and socket-timeout in app.sh of my python application. So the mod_wsgi-express server is configured with a higher timeout

ARGS="$ARGS --request-timeout 600"
ARGS="$ARGS --socket-timeout 600"

My application now wait 10 minutes before cancelling a request