0

I'm using Gunicorn behind nginx for a websocket and web server. According to the documentation, the only way websockets works in this configuration is if the number of workers is 1.

I would like to add a bit more scale - my service is likely to be I/O bound. Here is my systemd file:

[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
PermissionsStartOnly=True
Type=notify
DynamicUser=yes
RuntimeDirectory=gunicorn
WorkingDirectory=${appdir}
ExecStart=${gunicorndir}/${pyenvname}/bin/gunicorn \
          --access-logfile - \
          --workers 1 \
          -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker \
          --bind unix:/run/gunicorn.sock \
          wsgi:app
ExecReload=/bin/kill -s HUP $MAINPID
KillMode=mixed
TimeoutStopSec=5
PrivateTmp=true

[Install]
WantedBy=multi-user.target

and here's the nginx file:

server {
    listen 80;
    server_name 127.0.0.1 localhost ${domain} www.${domain} ${IP};

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root $appdir/static;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;
    }
}

What's the pattern for spinning up multiple gunicorn single instance workers?

aronchick
  • 6,786
  • 9
  • 48
  • 75

0 Answers0