Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IdleConnTimeout to Traefik's http.server settings #1340

Merged
merged 10 commits into from
Apr 4, 2017
2 changes: 2 additions & 0 deletions configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type GlobalConfiguration struct {
DefaultEntryPoints DefaultEntryPoints `description:"Entrypoints to be used by frontends that do not specify any entrypoint"`
ProvidersThrottleDuration flaeg.Duration `description:"Backends throttle duration: minimum duration between 2 events from providers before applying a new configuration. It avoids unnecessary reloads if multiples events are sent in a short amount of time."`
MaxIdleConnsPerHost int `description:"If non-zero, controls the maximum idle (keep-alive) to keep per-host. If zero, DefaultMaxIdleConnsPerHost is used"`
IdleTimeout flaeg.Duration `description:"maximum amount of time an idle (keep-alive) connection will remain idle before closing itself."`
InsecureSkipVerify bool `description:"Disable SSL certificate verification"`
Retry *Retry `description:"Enable retry sending request if network error"`
Docker *provider.Docker `description:"Enable Docker backend"`
Expand Down Expand Up @@ -467,6 +468,7 @@ func NewTraefikConfiguration() *TraefikConfiguration {
DefaultEntryPoints: []string{},
ProvidersThrottleDuration: flaeg.Duration(2 * time.Second),
MaxIdleConnsPerHost: 200,
IdleTimeout: flaeg.Duration(180 * time.Second),
CheckNewVersion: true,
},
ConfigFile: "",
Expand Down
14 changes: 12 additions & 2 deletions docs/toml.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@
#
# ProvidersThrottleDuration = "2s"

# IdleTimeout: maximum amount of time an idle (keep-alive) connection will remain idle before closing itself.
# This is set to enforce closing of stale client connections.
# Can be provided in a format supported by [time.ParseDuration](https://golang.org/pkg/time/#ParseDuration) or as raw
# values (digits). If no units are provided, the value is parsed assuming seconds.
#
# Optional
# Default: "180s"
#
# IdleTimeout = "360s"

# If non-zero, controls the maximum idle (keep-alive) to keep per-host. If zero, DefaultMaxIdleConnsPerHost is used.
# If you encounter 'too many open files' errors, you can either change this value, or change `ulimit` value.
#
Expand Down Expand Up @@ -1648,12 +1658,12 @@ RefreshSeconds = 15

```

Items in the dynamodb table must have three attributes:
Items in the dynamodb table must have three attributes:


- 'id' : string
- The id is the primary key.
- 'name' : string
- The name is used as the name of the frontend or backend.
- 'frontend' or 'backend' : map
- This attribute's structure matches exactly the structure of a Frontend or Backend type in traefik. See types/types.go for details. The presence or absence of this attribute determines its type. So an item should never have both a 'frontend' and a 'backend' attribute.
- This attribute's structure matches exactly the structure of a Frontend or Backend type in traefik. See types/types.go for details. The presence or absence of this attribute determines its type. So an item should never have both a 'frontend' and a 'backend' attribute.
9 changes: 8 additions & 1 deletion docs/user-guide/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,11 @@ defaultEntryPoints = ["http"]
headerField = "X-WebAuth-User"
[entryPoints.http.auth.basic]
users = ["test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"]
```
```

## Override the Traefik HTTP server IdleTimeout and/or throttle configurations from re-loading too quickly

```
IdleTimeout = "360s"
ProvidersThrottleDuration = "5s"
```
10 changes: 5 additions & 5 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ import (
"reflect"
"regexp"
"sort"
"sync"
"syscall"
"time"

"sync"

"github.com/codegangsta/negroni"
"github.com/containous/mux"
"github.com/containous/traefik/cluster"
Expand Down Expand Up @@ -532,9 +531,10 @@ func (server *Server) prepareServer(entryPointName string, router *middlewares.H
}

return &http.Server{
Addr: entryPoint.Address,
Handler: negroni,
TLSConfig: tlsConfig,
Addr: entryPoint.Address,
Handler: negroni,
TLSConfig: tlsConfig,
IdleTimeout: time.Duration(server.globalConfiguration.IdleTimeout),
}, nil
}

Expand Down