Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle backlog on UNIX socket too #2493

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pinaraf
Copy link

@pinaraf pinaraf commented Oct 17, 2022

The cheaper subsystem specifies that "backlog is only available on Linux and only on TCP sockets (not UNIX domain sockets)." This commit specifically implement this: UNIX domain socket support for backlog on Linux, using Netlink to call the kernel and get the queue status.

The cheaper subsystem specifies that "backlog is only available on Linux
and only on TCP sockets (not UNIX domain sockets)."
This commit specifically implement this: UNIX domain socket support for
backlog on Linux, using Netlink to call the kernel and get the queue status.
@pinaraf
Copy link
Author

pinaraf commented Oct 17, 2022

Note: this has been successfully tested locally, on a debian testing system, with the following:

WSGI app:

#hello.py
import time

def application(env, start_response):
    time.sleep(10)
    start_response('200 OK', [('Content-Type','text/html')])
    return [b"Hello World\n"]

uwsgi launch:

uwsgi --http-socket /tmp/uwsgi.sock --plugin python3 --module hello --master --processes 500 --plugin cheaper_busyness --cheaper-algo busyness --cheaper 5 --cheaper-initial 10 --cheaper-overload 20 --cheaper-step 2 --cheaper-busyness-multiplier 10 --cheaper-busyness-min 20 --cheaper-busyness-max 70 --cheaper-busyness-backlog-alert 16 --cheaper-busyness-backlog-step 2

curl to fill the uwsgi queue:

for i in `seq -w 1 100` ; do curl --unix-socket /tmp/uwsgi.sock http://127.0.0.1:9090/ &> /tmp/curl$i.txt & done

extract from uwsgi output with the patch:

[busyness] 72 requests in listen queue, spawning 2 emergency worker(s) (20)!

Without this patch, the previous output never shows, showing the backlog alert system is broken, and thus the recommended settings are currently unsafe: for cheaper-overload, a high value is recommended, but it can not be properly used if there is no backlog alert to catch load spikes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant