mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
The current transport setup is using mutex lock for synchronization. This could work ok in normal device, but on low capacity routers, this high contention may affect the performance, causing ctrld hangs. Instead of using mutex lock, using atomic operation for synchronization yield a better performance: - There's no lock, so other requests won't be blocked. And even theses requests use old broken transport, it would be fine, because the client will retry them later. - The setup transport is now done once, on demand when the transport is accessed, or when signal rebootsrapping. The first call to dohTransport will block others, but the transport is warmup before ctrld start serving requests, so client requests won't be affected. That helps ctrld handling the requests better when running on low capacity device. Further more, the transport configuration is also tweaked for better default performance: - MaxIdleConnsPerHost is set to 100 (default is 2), which allows more connections to be reused, reduce the load to open/close connections on demand. See [1] for a real example. - Due to the raising of MaxIdleConnsPerHost, once the transport is GC-ed, it must explicitly close its idle connections. - TLS client session cache is now enabled. Last but not least, the upstream ping process is also reworked. DoH transport is an HTTP transport, so doing a HEAD request is enough to warmup the transport, instead of doing a full DNS query. [1]: https://gitlab.com/gitlab-org/gitlab-pages/-/merge_requests/274
10 lines
189 B
Go
10 lines
189 B
Go
//go:build qf
|
|
|
|
package ctrld
|
|
|
|
import "net/http"
|
|
|
|
func (uc *UpstreamConfig) setupDOH3Transport() {}
|
|
|
|
func (uc *UpstreamConfig) doh3Transport(dnsType uint16) http.RoundTripper { return nil }
|