Skip to content

Commit a092b00

Browse files
authored
Merge pull request #488 from Dstack-TEE/feat/cvm-conntrack
feat: add conntrack sysctl config for CVM guest
2 parents 82f72ef + f5dc822 commit a092b00

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

basefiles/sysctl.d/99-dstack.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# SPDX-FileCopyrightText: 2025 Phala Network <dstack@phala.network>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# Increase conntrack table for high-concurrency gateway/proxy workloads.
5+
# Default 262144 is insufficient when proxying >100K concurrent connections.
6+
net.netfilter.nf_conntrack_max = 2097152

docs/deployment.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,36 @@ The CID range conflicts with existing VMs.
524524
cid_pool_size = 1000
525525
```
526526

527+
### High-concurrency deployments: conntrack table full
528+
529+
When running Gateway with many concurrent connections (>100K), the host's conntrack table may fill up, causing silent packet drops:
530+
531+
```
532+
dmesg: nf_conntrack: table full, dropping packet
533+
```
534+
535+
Each proxied connection creates multiple conntrack entries (client→gateway, gateway→WireGuard→backend). The default `nf_conntrack_max` (typically 262,144) is insufficient for high-concurrency gateways.
536+
537+
**Fix:**
538+
539+
```bash
540+
# Check current limit
541+
sysctl net.netfilter.nf_conntrack_max
542+
543+
# Increase for production (persistent)
544+
echo "net.netfilter.nf_conntrack_max = 1048576" >> /etc/sysctl.d/99-dstack.conf
545+
echo "net.netfilter.nf_conntrack_buckets = 262144" >> /etc/sysctl.d/99-dstack.conf
546+
sysctl -p /etc/sysctl.d/99-dstack.conf
547+
```
548+
549+
Also increase inside bridge-mode CVMs if they handle many connections:
550+
551+
```bash
552+
sysctl -w net.netfilter.nf_conntrack_max=524288
553+
```
554+
555+
**Sizing rule of thumb:** Set `nf_conntrack_max` to at least 4× your target concurrent connection count (each connection may use 2-3 conntrack entries across NAT/bridge layers).
556+
527557
### Error: Operation not permitted when building guest image
528558

529559
Ubuntu 23.10+ restricts unprivileged user namespaces:

0 commit comments

Comments
 (0)