Browse Source

uwsgi: use multiple http router processes for 30% performance gain

When using a single http router process (the default when --http is used),
all CPU cores were not saturated. I think this is because the single http
router process became CPU bound and the bottleneck. Thus, use
--http-processes PROCS to have one router process per core. This enables
all cores to be saturated and improved throughput by 30% on my setup.

I learned about --http-processes from the creator of uWSGI on the uWSGI
mailing list:

http://lists.unbit.it/pipermail/uwsgi/2013-September/006422.html
Malcolm Evershed 12 years ago
parent
commit
ff378121d9
1 changed files with 6 additions and 1 deletions
  1. 6 1
      uwsgi/setup.py

+ 6 - 1
uwsgi/setup.py

@@ -9,9 +9,14 @@ uwsgi = os.path.expanduser('~/FrameworkBenchmarks/installs/py2/bin/uwsgi')
 PROCS = multiprocessing.cpu_count()
 
 def start(args):
+    # --http and --http-processes create http router processes that process the
+    # incoming connections and pass them to the worker processes (-p). We use
+    # PROCS number of http router processes so that a single router process
+    # doesn't become a bottleneck.
     subprocess.Popen(
         uwsgi + ' --master -L -l 5000 --gevent 1000 --http :8080 --http-keepalive ' +
-        '-p ' + str(PROCS) + ' -w hello --add-header "Connection: keep-alive" ' +
+        ' --http-processes ' + str(PROCS) + ' -p ' + str(PROCS) + ' -w hello ' +
+        ' --add-header "Connection: keep-alive" ' +
         ' --pidfile /tmp/uwsgi.pid',
         shell=True, cwd="uwsgi")
     return 0