1

Using mod_wsgi under Apache, in daemon mode, on Ubuntu, to serve rest api calls from python.

Generally calls take about 0.5 seconds but occasionally they peak at 5 seconds. We are running approximately 40 daemon processes all restricted to a single thread. The server has lots of memory.

These 5 second peaks appear to occur even when the rest call is trivial, little more than "hello world" with a sleep.

My suspicion is that wsgi processes are being swapped by python or the os out but I have little evidence to support this. I also attempted to use nginx/uwsgi with the never-swap parameter and this did not resolve the problem.

Nick Brett
  • 11
  • 2
  • Why are you mentioning both mod_wsgi and uwsgi in the sense that you are saying 'suspicion is that uwsgi processes' when initially seeming to talk about mod_wsgi? They are different things. BTW, 40 processes is quite a lot and depending on the number of CPUs could be excessive and a problem in itself. Why not use multithreaded processes? – Graham Dumpleton May 04 '15 at 10:28
  • For uWSGI you can get some extensive status info for workers output with Stats Server: http://uwsgi-docs.readthedocs.org/en/latest/StatsServer.html - also Apache has mod_status http://httpd.apache.org/docs/current/mod/mod_status.html – Mikko Ohtamaa May 04 '15 at 10:35
  • 1
    Also running some basic monitoring like Zabbix or Munin on your server gives information of OS activities and helps resolve issues like this. – Mikko Ohtamaa May 04 '15 at 10:40
  • Graham I corrected the mention of uwsgi processes. I tested both apache/mod_wsgi and nginx/uwsgi separately, both had the problem. I do not believe the CPU is under load. Yes I can see that threading might help but it's not my code and python is not my language, I believe I would need to verify fully that the code was thread safe which in other languages is non trivial. – Nick Brett May 04 '15 at 11:07
  • Use of mod_status alone for Apache isn't likely going to help with this as its reporting is a bit crude. Recent versions of mod_wsgi have inbuilt monitoring for Apache as a whole which helps to make better use of underlying data that mod_status is based on, plus an as yet unreleased version of mod_wsgi has even more monitoring related to daemon processes specifically. Only problem is that there is no adapter for getting this all out to a separate monitoring system, so would need to put something together to do that. – Graham Dumpleton May 04 '15 at 12:23

0 Answers0