From d906732ef4c4de8ba6a7552192b47c06ee0dfbbc Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Thu, 21 Apr 2022 18:53:17 +0300 Subject: [PATCH] [#146] Update default values for HTTP_GW_READ/WRITE_TIMEOUT 10 minute upload and 5 minute download timeouts are long enough to handle average size objects in the real networks. For big data streams these timeouts should be disabled. Signed-off-by: Alex Vanin --- README.md | 5 +++++ config/config.env | 4 ++-- config/config.yaml | 4 ++-- settings.go | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8126473..7a0f80a 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,11 @@ You can tune HTTP read and write buffer sizes as well as timeouts with `HTTP_GW_WEB_WRITE_BUFFER_SIZE` and `HTTP_GW_WEB_WRITE_TIMEOUT` environment variables. +**Note:** to allow upload and download of big data streams, disable read +and write timeouts correspondingly. To do that, set `HTTP_GW_WEB_READ_TIMEOUT=0` +and `HTTP_GW_WEB_WRITE_TIMEOUT=0`. Otherwise, HTTP Gateway will terminate +request with data stream after timeout. + `HTTP_GW_WEB_STREAM_REQUEST_BODY` environment variable can be used to disable request body streaming (effectively it'll make gateway accept file completely first and only then try sending it to NeoFS). diff --git a/config/config.env b/config/config.env index fffa851..564b2dd 100644 --- a/config/config.env +++ b/config/config.env @@ -53,11 +53,11 @@ HTTP_GW_WRITE_BUFFER_SIZE=4096 # the full request including body. The connection's read # deadline is reset when the connection opens, or for # keep-alive connections after the first byte has been read. -HTTP_GW_READ_TIMEOUT=15s +HTTP_GW_READ_TIMEOUT=10m # WriteTimeout is the maximum duration before timing out # writes of the response. It is reset after the request handler # has returned. -HTTP_GW_WRITE_TIMEOUT=1m +HTTP_GW_WRITE_TIMEOUT=5m # StreamRequestBody enables request body streaming, # and calls the handler sooner when given body is # larger then the current limit. diff --git a/config/config.yaml b/config/config.yaml index 26c0d30..7cf3e5f 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -50,12 +50,12 @@ web: # the full request including body. The connection's read # deadline is reset when the connection opens, or for # keep-alive connections after the first byte has been read. - read_timeout: 15s + read_timeout: 10m # WriteTimeout is the maximum duration before timing out # writes of the response. It is reset after the request handler # has returned. - write_timeout: 1m + write_timeout: 5m # StreamRequestBody enables request body streaming, # and calls the handler sooner when given body is diff --git a/settings.go b/settings.go index 624a786..62af367 100644 --- a/settings.go +++ b/settings.go @@ -107,8 +107,8 @@ func settings() *viper.Viper { // web-server: v.SetDefault(cfgWebReadBufferSize, 4096) v.SetDefault(cfgWebWriteBufferSize, 4096) - v.SetDefault(cfgWebReadTimeout, time.Second*15) - v.SetDefault(cfgWebWriteTimeout, time.Minute) + v.SetDefault(cfgWebReadTimeout, time.Minute*10) + v.SetDefault(cfgWebWriteTimeout, time.Minute*5) v.SetDefault(cfgWebStreamRequestBody, true) v.SetDefault(cfgWebMaxRequestBodySize, fasthttp.DefaultMaxRequestBodySize)