mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-05-17 08:36:55 +03:00
lib/httpserver: option for disabling HTTP keep-alives (#9125)
### Describe Your Changes Some network configurations may not work optimally with long-lived connections. \ Address the issue described by #2395 for other components. ### Checklist The following checks are **mandatory**: - [x] My change adheres to [VictoriaMetrics contributing guidelines](https://docs.victoriametrics.com/victoriametrics/contributing/#pull-request-checklist). --------- Signed-off-by: Aleksandr Frolov <fxrlv@nebius.com> Co-authored-by: Aliaksandr Valialkin <valyala@gmail.com> Co-authored-by: Max Kotliar <kotlyar.maksim@gmail.com> Co-authored-by: Roman Khavronenko <hagen1778@gmail.com> Co-authored-by: Roman Khavronenko <roman@victoriametrics.com>
This commit is contained in:
@@ -54,6 +54,7 @@ var (
|
||||
flagsAuthKey = flagutil.NewPassword("flagsAuthKey", "Auth key for /flags endpoint. It must be passed via authKey query arg. It overrides -httpAuth.*")
|
||||
pprofAuthKey = flagutil.NewPassword("pprofAuthKey", "Auth key for /debug/pprof/* endpoints. It must be passed via authKey query arg. It overrides -httpAuth.*")
|
||||
|
||||
disableKeepAlive = flag.Bool("http.disableKeepAlive", false, "Whether to disable HTTP keep-alive for incoming connections at -httpListenAddr")
|
||||
disableResponseCompression = flag.Bool("http.disableResponseCompression", false, "Disable compression of HTTP responses to save CPU resources. By default, compression is enabled to save network bandwidth")
|
||||
maxGracefulShutdownDuration = flag.Duration("http.maxGracefulShutdownDuration", 7*time.Second, `The maximum duration for a graceful shutdown of the HTTP server. A highly loaded server may require increased value for a graceful shutdown`)
|
||||
shutdownDelay = flag.Duration("http.shutdownDelay", 0, `Optional delay before http server shutdown. During this delay, the server returns non-OK responses from /health page, so load balancers can route new requests to other servers`)
|
||||
@@ -165,6 +166,7 @@ func serveWithListener(addr string, ln net.Listener, rh RequestHandler, disableB
|
||||
|
||||
ErrorLog: logger.StdErrorLogger(),
|
||||
}
|
||||
s.s.SetKeepAlivesEnabled(!*disableKeepAlive)
|
||||
if *connTimeout > 0 {
|
||||
s.s.ConnContext = func(ctx context.Context, _ net.Conn) context.Context {
|
||||
timeoutSec := connTimeout.Seconds()
|
||||
|
||||
Reference in New Issue
Block a user