14

Is there a recommended way to diagnose the cause of task queue depth warnings like the one below from waitress? Perhaps there is some way to log queued tasks / requests?

2019-04-25 14:45:23,048 WARNI [waitress.queue:122][MainThread] Task queue depth is 2

I am testing a pyramid application on a local Windows 10 machine. I attempted to change the logging level for waitress and waitress.queue to "INFO" as well as setting the expose_tracebacks argument to True, but neither resulted in additional console output beyond the warning (no other waitress.serve default arguments have been altered).

Versions:

  • waitress version 1.3.0
  • pyramid version 1.10.4
  • python version 3.6.5
benvc
  • 14,448
  • 4
  • 33
  • 54

4 Answers4

16

The warning is very simple and directly related to the number of threads. Waitress defaults to 4 threads. A browser defaults to sending 6 requests at a time to each domain, so if you're loading a site with a few static assets (images/css/js) then you'll likely max that out and get a warning (6 - 4 = 2 as you're seeing in your post). If you bump the number of threads at least to 6 you should stop seeing the warning normally.

Michael Merickel
  • 23,153
  • 3
  • 54
  • 70
  • 5
    Tuning the number of threads did the trick. Useful references for future readers: [Max parallel http connections in a browser](https://stackoverflow.com/questions/985431/max-parallel-http-connections-in-a-browser) and [Tuning the number of waitress threads for production](https://groups.google.com/forum/#!topic/pylons-discuss/kGNO3ifiacY) – benvc Apr 26 '19 at 15:02
  • Does waitress run in a single process? If so, then is it limited by the GIL - that only 1 thread can run inside the GIL at a time? Is there any way to ask waitress to run in multiple processes? Is there any alternate server that allows spinning up multiple processes? – variable Mar 06 '20 at 09:12
  • 2
    I didn't immediately see how to adjust this if you're running via an *.ini file. This did the trick for my apps. Under [server:main], add the line threads = 8. Other options here are usually use = egg:waitress#main and host = 127.0.0.1, etc. – Michael Kennedy Dec 09 '20 at 02:01
1

It's basically an INFO (instead of WARNING) saying there are more requests than currently idle threads.

You can either bump up the threads or silence the waitress logging completely. Especially considering due to the waitress' default logging setup, it could interfere with the application loggings.

https://github.com/Pylons/waitress/issues/133#issuecomment-629992140

Jackie
  • 25,199
  • 6
  • 33
  • 24
0

The queue length refers to the number of requests waiting for a thread. The queue length can be configured by a backlog argument, passed to waitress.serve(). The default value is 1024. Ref

0

To fix it do threads=100

 serve(apiview.app, host="0.0.0.0", port=8080, threads=100)
realPro
  • 1,713
  • 3
  • 22
  • 34