gateway: custom-domain app lookup does an uncached DNS query on every connection, adding ~0.8–3s to the TLS handshake
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Tranquilla
- Stack tecnologico
- rust
- Ambito
- backend-api-design, networking, performance
Direzione di ricerca
Inizia in gateway/src/proxy/tls_passthough.rs da resolve_app_address(), quindi segui la sua chiamata da proxy_with_sni() attraverso tls_accept(). Verifica come viene creato il resolver hickory e come vengono gestiti i risultati TXT primari e legacy. Il lavoro è completato quando il riutilizzo del resolver e dell’indirizzo dell’applicazione rispetta il TTL, un risultato primario non viene ritardato dalla ricerca legacy e gli handshake dei domini personalizzati evitano costi DNS ripetuti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
For a custom domain (an SNI that isn't a <app-id>.<base-domain> subdomain), the gateway looks up the target app via DNS on every connection, before the TLS handshake completes — so the delay shows up as handshake latency. The lookup is slow because it:
- Builds a new DNS resolver every call (
AsyncResolver::tokio_from_system_conf()), so nothing is cached between connections and the record TTL is never used. - Runs the primary and legacy TXT lookups with
tokio::join!and waits for both, putting a slow/negative legacy lookup on the critical path.
This is worst when the gateway's resolver is slow — e.g. a CVM on QEMU user-mode (SLIRP) networking, where DNS is forwarded and uncached. Subdomain-routed apps skip the lookup and are unaffected.
Code
gateway/src/proxy/tls_passthough.rs, resolve_app_address() (called per connection from proxy_with_sni(), before tls_accept()):
let resolver = hickory_resolver::AsyncResolver::tokio_from_system_conf()?; // (1) new resolver every call
// ...
let (lookup, lookup_legacy) = tokio::join!( // (2) waits for BOTH; legacy is usually NXDOMAIN
resolver.txt_lookup(txt_domain),
resolver.txt_lookup(txt_domain_legacy),
);
Evidence
TLS-handshake time against one gateway, over loopback (no internet RTT), 18 samples each:
| SNI | pre-handshake work | median | max |
|---|---|---|---|
| custom domain | DNS lookup + handshake | 820 ms | 3373 ms |
<app-id>.<base> subdomain |
no DNS | 10 ms | 16 ms |
The ~810 ms gap is entirely the DNS step. Adding the missing legacy TXT record (so the second lookup isn't NXDOMAIN) dropped the median to ~499 ms — confirming the join!-on-both cost, but most of the delay is the per-connection uncached resolver.
Suggested fix
- Build the resolver once and reuse it (hickory caches by TTL).
- Cache resolved app-addresses by record TTL so steady-state connections skip DNS.
- Make the legacy lookup a fallback (only on primary miss), not a
join!that always waits.
(1)+(2) should bring custom-domain connections down to the subdomain baseline.
- Lingua principale
- Rust
- Stelle
- 546
- Fork
- 96
- Merge medio
- 19h 22m
- PR unite (30g)
- 109
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Dstack-TEE/dstack
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
Dstack-TEE/dstack#1301 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
Dstack-TEE/dstack#1300 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
Dstack-TEE/dstack#1299 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
Dstack-TEE/dstack#1298 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
Dstack-TEE/dstack#1297 ·
Tutte le issue di Dstack-TEE/dstack
Issue simili
-
risk:low runtime status:in-progress type:test
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
zeroclaw-labs/zeroclaw#11023 ·
-
good first issue refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
EricSpencer00/Resilient#4835 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
bisq-network/bisq-musig#204 ·
-
agent:ready documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
cesarferreira/stax#890 ·