Skip to content

Commit

Permalink
docs: blocking threads feature page missing [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
joseluisq committed Apr 30, 2023
1 parent f8fca0a commit e0ae5a7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
17 changes: 17 additions & 0 deletions docs/content/features/blocking-threads.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Blocking Threads Customization

**SWS** allows limiting the number of blocking threads powered by the [Tokio](https://tokio.rs/) runtime.

This feature can be controlled by the numeric `-b, --max-blocking-threads` option or the equivalent [SERVER_MAX_BLOCKING_THREADS](./../configuration/environment-variables.md#server_max_blocking_threads) env.

!!! info "WebAssembly"
We use `20` in [Wasm](https://webassembly.org/) by default and `512` in native environments (Tokio's default). See [Tokio ` max_blocking_threads` API](https://docs.rs/tokio/latest/tokio/runtime/struct.Builder.html#method.max_blocking_threads) for more details.

Below is an example.

```sh
static-web-server \
--port 8787 \
--root ./my-public-dir \
--max-blocking-threads 20
```
7 changes: 6 additions & 1 deletion docs/content/features/worker-threads.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

**SWS** allows customizing the number of worker threads powered by the [Tokio](https://tokio.rs/) runtime.

See [Tokio ` worker_threads` API](https://docs.rs/tokio/latest/tokio/runtime/struct.Builder.html#method.worker_threads).

This feature can be controlled by the numeric `-n, --threads-multiplier` option or the equivalent [SERVER_THREADS_MULTIPLIER](./../configuration/environment-variables.md#server_threads_multiplier) env.

## Worker threads multiplier
Expand All @@ -21,8 +23,11 @@ The formula used is the following:
!!! tip "Tip"
When the `--threads-multiplier` input value is `0` or `1` then one thread per core is used (default value).

!!! info "WebAssembly"
We use `2` threads per core in [Wasm](https://webassembly.org/) and `1` in native environments by default.

!!! warn "Warn"
The number of worker threads result should be a number between `1` and `32,768` though it is advised to keep this value on the smaller side. See [Tokio ` worker_threads` API](https://docs.rs/tokio/1.12.0/tokio/runtime/struct.Builder.html#method.worker_threads) for more details.
The number of worker threads resulted should be a number between `1` and `32,768` though it is advised to keep this value on the smaller side. See [Tokio ` worker_threads` API](https://docs.rs/tokio/latest/tokio/runtime/struct.Builder.html#method.worker_threads) for more details.

Below is an example of how to adjust the number of worker threads.

Expand Down
1 change: 1 addition & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ nav:
- 'Graceful Shutdown': 'features/graceful-shutdown.md'
- 'File Descriptor Socket Passing': './features/file-descriptor-socket-passing.md'
- 'Worker Threads Customization': 'features/worker-threads.md'
- 'Blocking Threads Customization': 'features/blocking-threads.md'
- 'Error Pages': 'features/error-pages.md'
- 'Custom HTTP Headers': 'features/custom-http-headers.md'
- 'URL Rewrites': 'features/url-rewrites.md'
Expand Down

0 comments on commit e0ae5a7

Please sign in to comment.