Skip to content

Commit 43ffb4d

Browse files
authored
Enable server SSH pool by default (#3981)
1 parent 9c1e460 commit 43ffb4d

4 files changed

Lines changed: 11 additions & 5 deletions

File tree

mkdocs/docs/guides/server-deployment.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ description: Deploying the dstack server
55

66
The `dstack` server can run on your laptop or any environment with access to the cloud and on-prem clusters you plan to use.
77

8-
The minimum hardware requirements for running the server are 1 CPU and 1GB of RAM.
8+
??? info "Hardware requirements"
9+
The minimum hardware requirements for running the server are 1 CPU and 1GB of RAM. The recommended RAM is
10+
"8MB × number of active instances". For example, a server with 1000 active instances should have 8GB of RAM.
11+
You can set the `DSTACK_SERVER_SSH_POOL_DISABLED` env var to minimize RAM usage at the expense of slower processing.
912

1013
=== "pip"
1114
> The server can be set up via `pip` on Linux, macOS, and Windows (via WSL 2). It requires Git and OpenSSH.
@@ -43,7 +46,7 @@ The minimum hardware requirements for running the server are 1 CPU and 1GB of RA
4346
</div>
4447

4548
=== "Docker"
46-
> To deploy the server most reliably, it's recommended to use `dstackai/dstack` Docker image.
49+
> For production deployments, it's recommended to use `dstackai/dstack` Docker image.
4750

4851
<div class="termy">
4952

mkdocs/docs/reference/env.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ For more details on the options below, refer to the [server deployment](../guide
146146
- `DSTACK_SERVER_SSHPROXY_ENFORCED`{ #DSTACK_SERVER_SSHPROXY_ENFORCED } – When set to any value, restricts all SSH connections to go through the SSH proxy.
147147
- `DSTACK_SERVER_JOB_NETWORK_MODE`{ #DSTACK_SERVER_JOB_NETWORK_MODE } – Controls the network mode assigned to jobs. Accepts an integer value: `1` forces bridge networking for single-node jobs while distributed tasks still use host networking; `2` uses host networking whenever the job occupies a full instance (default); `3` forces bridge networking for all jobs including distributed tasks.
148148
- `DSTACK_SERVER_SSH_CONNECT_TIMEOUT`{ #DSTACK_SERVER_SSH_CONNECT_TIMEOUT } – The SSH `ConnectTimeout` for server-instance connections, in seconds. Defaults to `3`. Increase if there are high-latency links between the server and instances.
149+
- `DSTACK_SERVER_SSH_POOL_DISABLED`{ #DSTACK_SERVER_SSH_POOL_DISABLED } – Disables the reuse of server SSH connections to instances. If set, significantly decreases server RAM usage, but
150+
slows down processing and may cause CPU spikes due to frequent SSH-connection establishment.
149151

150152
??? info "Internal environment variables"
151153
The following environment variables are intended for development purposes:

src/dstack/_internal/server/app.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ async def lifespan(app: FastAPI):
171171
init_default_storage()
172172
if settings.SERVER_SSH_POOL_ENABLED:
173173
await run_async(instance_connection_pool.startup_cleanup)
174+
else:
175+
logger.info("Server SSH pool is disabled")
174176
scheduler = None
175177
pipeline_manager = None
176178
if settings.SERVER_BACKGROUND_PROCESSING_ENABLED:

src/dstack/_internal/server/settings.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,8 @@
149149
os.getenv("DSTACK_SERVER_LOG_QUOTA_PER_JOB_HOUR", 50 * 1024 * 1024) # 50 MB
150150
)
151151

152-
# TODO: Replace DSTACK_SERVER_SSH_POOL_ENABLED with DSTACK_SERVER_SSH_POOL_DISABLED
153-
# as pool becomes opt-out and document the env var.
154-
SERVER_SSH_POOL_ENABLED = os.getenv("DSTACK_SERVER_SSH_POOL_ENABLED") is not None
152+
SERVER_SSH_POOL_DISABLED = os.getenv("DSTACK_SERVER_SSH_POOL_DISABLED") is not None
153+
SERVER_SSH_POOL_ENABLED = not SERVER_SSH_POOL_DISABLED
155154
SERVER_SSH_CONNECT_TIMEOUT = int(os.getenv("DSTACK_SERVER_SSH_CONNECT_TIMEOUT", 3))
156155

157156
# Development settings

0 commit comments

Comments
 (0)