Worker Threads Customization¶
SWS allows customizing the number of worker threads powered by the Tokio runtime.
This feature can be controlled by the numeric
-n, --threads-multiplier option or the equivalent SERVER_THREADS_MULTIPLIER env.
Worker threads multiplier¶
The value of
-n, --threads-multiplier works as multiplier digits to determine the number of worker threads used by the server.
Multiplying this input number by the number of system CPUs.
The formula used is the following:
worker threads = number of CPUs * n
n is the input value of
For example: If there are
4 available CPUs and the
8 then the total of worker threads to use will be
--threads-multiplier input value is
1 then one thread per core is used (default value).
2 threads per core in Wasm and
1 in native environments by default.
The number of worker threads resulted should be a number between
32,768 though it is advised to keep this value on the smaller side. See Tokio
worker_threads API for more details.
Below is an example of how to adjust the number of worker threads.
static-web-server \ --port 8787 \ --root ./my-public-dir \ # NOTE: "8" gets multiplied by the number of the available cores. --threads-multiplier 8