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

sidecar: allow custom http con pool size fix #1953 #1955

Closed
wants to merge 0 commits into from

Conversation

blockloop
Copy link
Contributor

@blockloop blockloop commented Jan 8, 2020

closed and reopened as #1969

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

Some suggestions but generally I am ok with this.

Totally makes sense to adjust default values for certain cases like yours.

CHANGELOG.md Outdated
@@ -13,6 +13,7 @@ We use *breaking* word for marking changes that are not backward compatible (rel

### Fixed

- [#1955](https://github.com/thanos-io/thanos/pull/1955) Sidecar: enable command line flag to set http connection pool size `--prometheus.connection-pool-size`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's rather Added I think. Also please update #Unreleased section instead as v0.10.0 is cut today.

Also:

Suggested change
- [#1955](https://github.com/thanos-io/thanos/pull/1955) Sidecar: enable command line flag to set http connection pool size `--prometheus.connection-pool-size`
- [#1955](https://github.com/thanos-io/thanos/pull/1955) Sidecar: Add command line flag to set http connection pool size `--prometheus.connection-pool-size`

@@ -45,6 +45,9 @@ func registerSidecar(m map[string]setupFunc, app *kingpin.Application) {
promReadyTimeout := cmd.Flag("prometheus.ready_timeout", "Maximum time to wait for the Prometheus instance to start up").
Default("10m").Duration()

connectionPoolSize := cmd.Flag("prometheus.connection-pool-size", "sets the MaxIdleConnsPerHost and MaxIdleConns when connecting to prometheus").
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would split it then to 2 separate flags. I think there are many use cases where those two should have different values allowing more than one spammy client.

) (*PrometheusStore, error) {
if logger == nil {
logger = log.NewNopLogger()
}
if client == nil {
t := http.DefaultTransport.(*http.Transport)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a common bug and let's avoid this. This will actually change the value for all clients used by this binary that derives from http.DefaultTransport

I would add some helper method in some Thanos package like exthttp that will literally create NewTransport:

func NewTransport() *http.Transport {
 return  &Transport{
	Proxy: ProxyFromEnvironment,
	DialContext: (&net.Dialer{
		Timeout:   30 * time.Second,
		KeepAlive: 30 * time.Second,
		DualStack: true,
	}).DialContext,
	ForceAttemptHTTP2:     true,
	MaxIdleConns:          100,
	IdleConnTimeout:       90 * time.Second,
	TLSHandshakeTimeout:   10 * time.Second,
	ExpectContinueTimeout: 1 * time.Second,
}
}

.. ideally let's also pass *http.Transport in constructor of PrometheusStore for extensibility (:

@blockloop
Copy link
Contributor Author

Hey @bwplotka I'll make these changes and push another PR. This was from the master branch of my fork

@bwplotka
Copy link
Member

bwplotka commented Jan 8, 2020

Sure, hope you can address my comments there (:

@blockloop
Copy link
Contributor Author

Yep will do. I already separated the two flags in the PR I made to receive. I was going to do that here also. I'll send up another PR shortly.

@blockloop
Copy link
Contributor Author

reopened as #1969

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants