Quadruple all HTTP timeouts to prevent timeout errors

- HTTP request timeout: 2s -> 8s
- Stats collection context timeout: 1s -> 4s
- HTTP read header timeout: 10s -> 40s

This should prevent timeout errors when the database is under load
or when complex queries take longer than expected (slow query
threshold is 50ms).
This commit is contained in:
2025-07-29 04:18:07 +02:00
parent 3338e92785
commit 1fded42651
4 changed files with 338174 additions and 1840750 deletions

View File

@@ -80,8 +80,8 @@ func (s *Server) handleStatusJSON() http.HandlerFunc {
}
return func(w http.ResponseWriter, r *http.Request) {
// Create a 1 second timeout context for this request
ctx, cancel := context.WithTimeout(r.Context(), 1*time.Second)
// Create a 4 second timeout context for this request
ctx, cancel := context.WithTimeout(r.Context(), 4*time.Second)
defer cancel()
metrics := s.streamer.GetMetrics()
@@ -214,8 +214,8 @@ func (s *Server) handleStats() http.HandlerFunc {
}
return func(w http.ResponseWriter, r *http.Request) {
// Create a 1 second timeout context for this request
ctx, cancel := context.WithTimeout(r.Context(), 1*time.Second)
// Create a 4 second timeout context for this request
ctx, cancel := context.WithTimeout(r.Context(), 4*time.Second)
defer cancel()
// Check if context is already cancelled