Browse Source

Common nginx and uWSGI config files for use with nginx+uWSGI combination

For tests that want to run uWSGI behind nginx speaking the uwsgi protocol,
these are common config files that can be used.

The combination of nginx+uWSGI is one of the fastest methods of running
WSGI apps as explained by:

http://lists.unbit.it/pipermail/uwsgi/2013-September/006431.html
Malcolm Evershed 12 years ago
parent
commit
00db67b3fa
3 changed files with 63 additions and 0 deletions
  1. 45 0
      config/nginx_uwsgi.conf
  2. 14 0
      config/uwsgi.ini
  3. 4 0
      config/uwsgi_stop.ini

+ 45 - 0
config/nginx_uwsgi.conf

@@ -0,0 +1,45 @@
+# This file is based on /usr/local/nginx/conf/nginx.conf.default.
+
+# One worker process per core
+worker_processes auto;
+
+events {
+    # This may need to be increased for the high-concurrency plaintext test.
+    worker_connections  1024;
+}
+
+http {
+    include       /usr/local/nginx/conf/mime.types;
+    default_type  application/octet-stream;
+
+    # turn off request logging for performance
+    access_log off;
+
+    # I think these only options affect static file serving
+    sendfile        on;
+    tcp_nopush      on;
+
+    # Allow many HTTP Keep-Alive requests in a single TCP connection before
+    # closing it (the default is 100). This will minimize the total number
+    # of TCP connections opened/closed. The problem is that this may cause
+    # some worker processes to be handling too connections relative to the
+    # other workers based on an initial imbalance, so this is disabled for
+    # now.
+#    keepalive_requests 1000;
+
+    #keepalive_timeout  0;
+    keepalive_timeout  65;
+
+    server {
+        # For information on deferred, see:
+        # http://nginx.org/en/docs/http/ngx_http_core_module.html#listen
+        # http://www.techrepublic.com/article/take-advantage-of-tcp-ip-options-to-optimize-data-transmission/
+        listen       8080 default_server deferred;
+        server_name  localhost;
+
+        location / {
+            uwsgi_pass unix:/tmp/uwsgi.sock;
+            include /usr/local/nginx/conf/uwsgi_params;
+        }
+    }    
+}

+ 14 - 0
config/uwsgi.ini

@@ -0,0 +1,14 @@
+[uwsgi]
+master
+; increase listen queue used for nginx connecting to uWSGI
+listen = 5000
+; for performance
+disable-logging
+; use UNIX sockets instead of TCP loopback for performance
+socket = /tmp/uwsgi.sock
+; allow nginx to access the UNIX socket
+chmod-socket = 666
+; avoid thundering herd problem http://uwsgi-docs.readthedocs.org/en/latest/articles/SerializingAccept.html
+thunder-lock
+; used by uwsgi_stop.ini
+pidfile = /tmp/uwsgi.pid

+ 4 - 0
config/uwsgi_stop.ini

@@ -0,0 +1,4 @@
+# If uWSGI was started with --ini uwsgi.ini, it can be stopped with --ini uwsgi_stop.ini
+
+[uwsgi]
+stop = /tmp/uwsgi.pid