Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between uWSGI's socket-timeout/http-timeout/harakiri?

I wrote a simple WSGI application (using Flask) served by uWSGI (i.e. no other HTTP server but uWSGI) which only supports a single PUT route using which clients can upload a file (potentially ~400MB in size), have it processed on the server and then sent back.

In the uWSGI logs, I noticed two kinds of timeout errors after some time. Usually it's a timeout when sending the response:

Feb 02 20:46:30 myserv uwsgi[18948]: uwsgi_response_sendfile_do() TIMEOUT !!!
Feb 02 20:46:30 myserv uwsgi[18948]: OSError: write error
Feb 02 20:46:30 myserv uwsgi[18948]: [pid: 18954|app: 0|req: 1795/3935] aa.bb.cc.dd () {32 vars in 455 bytes} [Fri Feb  2 20:46:06 2018] PUT /sample.exe => generated 0 bytes in 24314 msecs via sendfile() (HTTP/1.1 200) 6 headers in 258 bytes (3353 switches on core 0)

Sometimes though, it's also a timeout when receiving a PUT request:

Feb 03 20:18:32 signserv uwsgi[18948]: [pid: 18953|app: 0|req: 2975/5670] aa.bb.cc.dd () {32 vars in 455 bytes} [Sat Feb  3 20:18:02 2018] PUT /samplefile.exe => generated 0 bytes in 29499 msecs via sendfile() (HTTP/1.1 200) 6 headers in 258 bytes (2930 switches on core 0)
Feb 03 20:20:30 signserv uwsgi[18948]: [uwsgi-body-read] Timeout reading 16384 bytes. Content-Length: 354414781 consumed: 0 left: 354414781

Some debugging suggests that this typically happens with clients which are very slow (i.e. which have a high load).

I'd like to alleviate this by increasing some timeouts, but uWSGI appears to support a plethora of timeouts and it's not clear to me which of them are relevant here. I identified three timeouts which sound like I may want to increase them, but I have trouble finding documentation on how they differ:

  • socket-timeout
  • http-timeout
  • harakiri

Can anyone shed some light on what these timeouts affect, what their default values are and which (if any) of them should be adjusted to avoid above-mentioned issues?

like image 808
Frerich Raabe Avatar asked Feb 04 '18 18:02

Frerich Raabe


People also ask

What is socket in uWSGI?

HTTP socketsThe http-socket <bind> option will make uWSGI natively speak HTTP. If your web server does not support the uwsgi protocol but is able to speak to upstream HTTP proxies, or if you are using a service like Webfaction or Heroku to host your application, you can use http-socket .

What is uWSGI used for?

uWSGI is an open source software application that "aims at developing a full stack for building hosting services". It is named after the Web Server Gateway Interface (WSGI), which was the first plugin supported by the project.

What is lazy apps in uWSGI?

Remember: lazy-apps is different from lazy, the first one only instructs uWSGI to load the application one time per worker, while the second is more invasive (and generally discouraged) as it changes a lot of internal defaults.


1 Answers

In simple terms, the harakiri is uWSGI timeout and the http-timeout or the socket-timeout is a balancer/proxy-server timeout.

When these parameters differ, there can be confusion in logs.

like image 106
j0shu4b0y Avatar answered Oct 11 '22 17:10

j0shu4b0y