2019-02-26 13:50:07 +00:00
# MaxConnection
Limiting the Number of Simultaneous Clients
{: .subtitle }
![MaxConnection ](../assets/img/middleware/maxconnection.png )
To proactively prevent services from being overwhelmed with high load, a maximum connection limit can be applied.
## Configuration Examples
2019-03-29 11:34:05 +00:00
```yaml tab="Docker"
# Limiting to 10 simultaneous connections
labels:
- "traefik.http.middlewares.test-maxconn.maxconn.amount=10"
```
2019-04-03 12:32:04 +00:00
```yaml tab="Kubernetes"
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
2019-06-18 10:20:04 +00:00
name: test-maxconn
2019-04-03 12:32:04 +00:00
spec:
2019-06-18 10:20:04 +00:00
maxConn:
amount: 10
2019-04-03 12:32:04 +00:00
```
2019-04-15 16:22:07 +00:00
```json tab="Marathon"
"labels": {
"traefik.http.middlewares.test-maxconn.maxconn.amount": "10"
}
```
2019-04-08 15:14:08 +00:00
```yaml tab="Rancher"
# Limiting to 10 simultaneous connections
labels:
- "traefik.http.middlewares.test-maxconn.maxconn.amount=10"
```
2019-07-22 07:58:04 +00:00
```toml tab="File (TOML)"
2019-03-29 11:34:05 +00:00
# Limiting to 10 simultaneous connections
[http.middlewares]
2019-07-01 09:30:05 +00:00
[http.middlewares.test-maxconn.maxConn]
amount = 10
2019-03-29 11:34:05 +00:00
```
2019-02-26 13:50:07 +00:00
2019-07-22 07:58:04 +00:00
```yaml tab="File (YAML)"
# Limiting to 10 simultaneous connections
http:
middlewares:
test-maxconn:
maxConn:
amount: 10
```
2019-02-26 13:50:07 +00:00
## Configuration Options
2019-04-03 12:32:04 +00:00
### `amount`
2019-02-26 13:50:07 +00:00
The `amount` option defines the maximum amount of allowed simultaneous connections.
2019-07-22 07:58:04 +00:00
The middleware will return an `HTTP 429 Too Many Requests` if there are already `amount` requests in progress (based on the same `extractorFunc` strategy).
2019-02-26 13:50:07 +00:00
2019-07-22 07:58:04 +00:00
### `extractorFunc`
2019-02-26 13:50:07 +00:00
2019-07-22 07:58:04 +00:00
The `extractorFunc` defines the strategy used to categorize requests.
2019-02-26 13:50:07 +00:00
The possible values are:
- `request.host` categorizes requests based on the request host.
- `client.ip` categorizes requests based on the client ip.
- `request.header.ANY_HEADER` categorizes requests based on the provided `ANY_HEADER` value.