Skip to content

Unix socket support (refactored) - #9363

Open
dometto wants to merge 27 commits into
dask:mainfrom
dometto:unix_socket_alt
Open

Unix socket support (refactored)#9363
dometto wants to merge 27 commits into
dask:mainfrom
dometto:unix_socket_alt

Conversation

@dometto

@dometto dometto commented Sep 10, 2026

Copy link
Copy Markdown

This is a slightly refactored version of #9337, removing subclassing of the main TCP class for better isolation. Pasting the original description below.

Resolves #3630

This PR adds support for Unix Domain Sockets...

  1. as a protocol/backend in comms
  2. as an optional way to serve the dashboard server

The rationale for this is twofold:

  1. improved security
  2. improved performance

Test this branch with:

  1. the provided tests
  2. or by creating a cluster with the new protocol:
    cluster = LocalCluster(
        n_workers=2,
        protocol="uds",
    )
   # do something with the cluster here

New UDS backend

This is the main part of this PR. We implement a new backend UDS which subclasses the standard TCP classes. When setting protocol on a cluster/worker/scheduler to unix://, this backend is used. When a worker or scheduler is given an absolute path, it will use that absolute path to create the unix socket. If instead any other value is passed in (e.g. the default localhost), the backend will create the socket at a new temporary path.

Benefits

Performance

@mrocklin tested this:

I just benchmarked this on
a macbook as a consideration for Frisky and got a 1.5x speedup (15 GB/s ->
25 GB/s) and 3x latency reduction (18us -> 6us) compared to TCP.  Maybe
still not worth doing there though just due to code complexity and I've yet
to find a workload that's bound by network on localhost there.  Still
pretty cool though.

Security

UDS support is desireable for usecases where:

  • Multi-processing is preferable to multi-threading (so no inproc)
  • ucx is not available (e.g. not on Linux)
  • We care about other users (e.g. on a shared VM) not being able to access our data and processes (so no tcp).
    • within a single node, enabling TLS is not always feasible (in dask-labextension for instance), or desired (more overhead).

Dashboard listening on UDS

When the dashboard_url is set to an absolute path, or to unix://, listen on UDS instead of TCP. This can help prevent new CVE's of the form GHSA-c336-7962-wfj2

dometto added 27 commits July 23, 2026 15:59
Make get_uds_path() respect XDG_RUNTIME_DIR and dask.config['temporary-directory']
This is easier than removing on stop. It technically introduces a race condition, but so would removing on stop, I think.
On Linux we need to unset XDG_RUNTIME_DIR when we're not testing it.
On Linux we need to unset XDG_RUNTIME_DIR when we're not testing it.
@github-actions

Copy link
Copy Markdown
Contributor

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

    40 files  ±  0      40 suites  ±0   14h 35m 4s ⏱️ + 2m 17s
 4 178 tests + 18   3 994 ✅ + 18    178 💤 ± 0   6 ❌ ±0 
81 320 runs  +359  77 048 ✅ +334  4 259 💤 +18  13 ❌ +7 

For more details on these failures, see this check.

Results for commit 5e60065. ± Comparison against base commit dc182bd.

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.

Investigate UNIX domain sockets

1 participant