Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ sha256sum.txt
# Test binary, build with `go test -c`
*.test
.coverprofile
prometheus-data
prometheus-data/
redis-data/
trickster-data
trips_*.gz

Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,11 @@ developer-stop:

.PHONY: developer-delete
developer-delete:
@cd docs/developer/environment && docker compose down
@cd docs/developer/environment && docker compose down -v --remove-orphans

.PHONY: developer-restart
developer-restart:
@cd docs/developer/environment && docker compose down && docker compose up -d
.PHONY: developer-recreate
developer-recreate: developer-delete
@cd docs/developer/environment && docker compose up -d

.PHONY: developer-seed-data
developer-seed-data:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ datasources:
editable: true
jsonData:
httpMethod: POST
- name: "7: Trickster | ALB 1"
type: prometheus
access: proxy
orgId: 1
uid: ds_prom_trickster_alb_1
url: http://host.docker.internal:8480/alb1
version: 1
editable: true
jsonData:
httpMethod: POST

# Mockster (Prom API Simulator)
- name: sim-direct
Expand Down
Empty file.
4 changes: 2 additions & 2 deletions docs/developer/environment/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
ports:
- 6379:6379
volumes:
- redis-data:/data
- ./docker-compose-data/redis-data:/data
command: redis-server --appendonly yes --stop-writes-on-bgsave-error no

# ui's
Expand Down Expand Up @@ -40,6 +40,7 @@ services:
image: prom/prometheus:v3.2.1
volumes:
- ./docker-compose-data/prometheus-config:/etc/prometheus
- ./docker-compose-data/prometheus-data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
Expand Down Expand Up @@ -153,4 +154,3 @@ services:

volumes:
influxdbv2:
redis-data:
6 changes: 5 additions & 1 deletion examples/conf/example.full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,13 @@ backends:
# keep_alive_timeout: 120s

# # max_idle_conns set the maximum concurrent keep-alive connections Trickster may have opened to this backend
# # additional requests will be queued. Default: 20
# # while no clients are being served. Default: 20
# max_idle_conns: 20

# # max_concurrent_conns set the maximum number of concurrent connections Trickster may have opened to this backend
# # additional requests will be queued. Default: 20
# max_concurrent_conns: 20

# # max_ttl defines the maximum allowed TTL for any object cached for this backend. default is 24 hours
# max_ttl: 24h

Expand Down
14 changes: 11 additions & 3 deletions pkg/backends/healthcheck/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,17 @@ func newHTTPClient(timeout time.Duration) *http.Client {
return http.ErrUseLastResponse
},
Transport: &http.Transport{
Dial: (&net.Dialer{KeepAlive: 5 * time.Second}).Dial,
MaxIdleConns: 32,
MaxIdleConnsPerHost: 32,
Dial: (&net.Dialer{
Timeout: timeout,
KeepAlive: time.Second * 30,
}).Dial,
MaxIdleConns: 1,
MaxIdleConnsPerHost: 1,
MaxConnsPerHost: 1,
IdleConnTimeout: time.Second * 30,
TLSHandshakeTimeout: timeout,
ExpectContinueTimeout: timeout,
ResponseHeaderTimeout: timeout,
},
}
}
2 changes: 2 additions & 0 deletions pkg/backends/options/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ const (
DefaultKeepAliveTimeout = 2 * time.Minute
// DefaultMaxIdleConns is the default number of Idle Connections in Backends' upstream client pools
DefaultMaxIdleConns = 20
// DefaultMaxConcurrentConns is the default max number of concurrent connections to the origin the Backend can use
DefaultMaxConcurrentConns = 20
// DefaultForwardedHeaders defines which class of 'Forwarded' headers are attached to upstream requests
DefaultForwardedHeaders = "standard"
// DefaultALBMechanismName defines the default ALB Mechanism Name
Expand Down
3 changes: 3 additions & 0 deletions pkg/backends/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ type Options struct {
Timeout time.Duration `yaml:"timeout,omitempty"`
// KeepAliveTimeout defines how long an open keep-alive HTTP connection remains idle before closing
KeepAliveTimeout time.Duration `yaml:"keep_alive_timeout,omitempty"`
// MaxConcurrentConns defines maximum number of open concurrent connections to maintain to the backend
MaxConcurrentConns int `yaml:"max_concurrent_conns,omitempty"`
// MaxIdleConns defines maximum number of open keep-alive connections to maintain
MaxIdleConns int `yaml:"max_idle_conns,omitempty"`
// CacheName provides the name of the configured cache where the backend client will store it's cache data
Expand Down Expand Up @@ -237,6 +239,7 @@ func New() *Options {
HealthCheck: ho.New(),
KeepAliveTimeout: DefaultKeepAliveTimeout,
MaxIdleConns: DefaultMaxIdleConns,
MaxConcurrentConns: DefaultMaxConcurrentConns,
MaxObjectSizeBytes: DefaultMaxObjectSizeBytes,
MaxTTL: DefaultMaxTTL,
NegativeCache: make(map[int]time.Duration),
Expand Down
7 changes: 7 additions & 0 deletions pkg/config/testdata/example.alb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ backends:
default:
timeout: 1m0s
keep_alive_timeout: 2m0s
max_concurrent_conns: 20
max_idle_conns: 20
cache_name: default
chunk_read_concurrency_limit: 16
Expand Down Expand Up @@ -37,6 +38,7 @@ backends:
origin_url: https://origin1/
timeout: 1m0s
keep_alive_timeout: 2m0s
max_concurrent_conns: 20
max_idle_conns: 20
cache_name: default
cache_key_prefix: origin1
Expand Down Expand Up @@ -73,6 +75,7 @@ backends:
origin_url: http://origin2
timeout: 1m0s
keep_alive_timeout: 2m0s
max_concurrent_conns: 20
max_idle_conns: 20
cache_name: default
cache_key_prefix: origin2
Expand Down Expand Up @@ -109,6 +112,7 @@ backends:
origin_url: http://prom1:9090
timeout: 1m0s
keep_alive_timeout: 2m0s
max_concurrent_conns: 20
max_idle_conns: 20
cache_name: default
cache_key_prefix: prom1:9090
Expand Down Expand Up @@ -144,6 +148,7 @@ backends:
origin_url: http://prom2:9090
timeout: 1m0s
keep_alive_timeout: 2m0s
max_concurrent_conns: 20
max_idle_conns: 20
cache_name: default
cache_key_prefix: prom2:9090
Expand Down Expand Up @@ -178,6 +183,7 @@ backends:
provider: alb
timeout: 1m0s
keep_alive_timeout: 2m0s
max_concurrent_conns: 20
max_idle_conns: 20
cache_name: default
chunk_read_concurrency_limit: 16
Expand Down Expand Up @@ -216,6 +222,7 @@ backends:
provider: alb
timeout: 1m0s
keep_alive_timeout: 2m0s
max_concurrent_conns: 20
max_idle_conns: 20
cache_name: default
chunk_read_concurrency_limit: 16
Expand Down
4 changes: 4 additions & 0 deletions pkg/config/testdata/example.auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ backends:
origin_url: https://example.com/
timeout: 1m0s
keep_alive_timeout: 2m0s
max_concurrent_conns: 20
max_idle_conns: 20
cache_name: default
cache_key_prefix: example.com
Expand Down Expand Up @@ -41,6 +42,7 @@ backends:
origin_url: https://example.com/
timeout: 1m0s
keep_alive_timeout: 2m0s
max_concurrent_conns: 20
max_idle_conns: 20
cache_name: default
cache_key_prefix: example.com
Expand Down Expand Up @@ -76,6 +78,7 @@ backends:
origin_url: https://example.com/
timeout: 1m0s
keep_alive_timeout: 2m0s
max_concurrent_conns: 20
max_idle_conns: 20
cache_name: default
cache_key_prefix: example.com
Expand Down Expand Up @@ -109,6 +112,7 @@ backends:
default:
timeout: 1m0s
keep_alive_timeout: 2m0s
max_concurrent_conns: 20
max_idle_conns: 20
cache_name: default
chunk_read_concurrency_limit: 16
Expand Down
1 change: 1 addition & 0 deletions pkg/config/testdata/example.full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ backends:
origin_url: http://prometheus:9090
timeout: 1m0s
keep_alive_timeout: 2m0s
max_concurrent_conns: 20
max_idle_conns: 20
cache_name: default
cache_key_prefix: prometheus:9090
Expand Down
1 change: 1 addition & 0 deletions pkg/config/testdata/exmple.sharding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ backends:
origin_url: http://prometheus:9090
timeout: 1m0s
keep_alive_timeout: 2m0s
max_concurrent_conns: 20
max_idle_conns: 20
cache_name: default
cache_key_prefix: prometheus:9090
Expand Down
1 change: 1 addition & 0 deletions pkg/config/testdata/simple.prometheus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ backends:
origin_url: http://prometheus:9090
timeout: 1m0s
keep_alive_timeout: 2m0s
max_concurrent_conns: 20
max_idle_conns: 20
cache_name: default
cache_key_prefix: prometheus:9090
Expand Down
1 change: 1 addition & 0 deletions pkg/config/testdata/simple.reverseproxycache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ backends:
origin_url: https://www.example.com
timeout: 1m0s
keep_alive_timeout: 2m0s
max_concurrent_conns: 20
max_idle_conns: 20
cache_name: default
cache_key_prefix: www.example.com
Expand Down
1 change: 1 addition & 0 deletions pkg/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func NewHTTPClient(o *bo.Options) (*http.Client, error) {
}).Dial,
MaxIdleConns: o.MaxIdleConns,
MaxIdleConnsPerHost: o.MaxIdleConns,
MaxConnsPerHost: o.MaxConcurrentConns,
IdleConnTimeout: o.KeepAliveTimeout,
TLSHandshakeTimeout: connectTimeout,
ExpectContinueTimeout: o.Timeout,
Expand Down
Loading