Apache mod_wsgi django enable multi-thread multi-process

会有一股神秘感。 提交于 2019-12-06 05:48:35

Setting a high number of threads in Python is usually a bad idea because of the Python GIL. And doing benchmark testing where you excessively overload the system is even worse as it jut exacerbates things and gives unreliable results. I'd recommend not running a Python web server which uses threading at over 40-60% capacity because once you push throughput higher, especially if more CPU bound, then things go rapidly down hill. Benchmarks which send max requests, do this very quickly and so are meaningless.

I would suggest watching the following two conference talk videos which goes into some of the issues.

As a general rule of thumb, do the following:

  • Use daemon mode.
  • Disable embedded mode using WSGIRestrictEmbedded On.
  • Use at most 5 threads per process, unless excessively I/O bound.
  • Use processes over threads, but don't get carried away with processes either.
  • Scale across multiple machines.
  • Instrument the WSGI server and application so now how it performs for real system.

For adding metrics to monitor mod_wsgi see:

If want to discuss metrics, use the mod_wsgi mailing list for latest information.


UPDATE 1

Also watch:

At the end of this it talks about various settings daemon mode you should look at and set. Also see the end of:

for some recommended defaults for daemon process settings.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!