Skip to content

Update connection pool config for proxy#666

Merged
mmatczuk merged 3 commits intomainfrom
mmt/pool_config
Jan 30, 2024
Merged

Update connection pool config for proxy#666
mmatczuk merged 3 commits intomainfrom
mmt/pool_config

Conversation

@mmatczuk
Copy link
Contributor

No description provided.

@mmatczuk mmatczuk requested a review from a team as a code owner January 29, 2024 16:39
Makefile Outdated
.PHONY: run-race
run-race: .forwarder.yaml
run-race:
@go run ./cmd/forwarder run --config-file .forwarder.yaml
Copy link
Contributor

Choose a reason for hiding this comment

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

It's lacking --race.

Remove MaxIdleConns meaning no limit.
Set MaxIdleConnsPerHost to 512 as it must be limited, zero value implies the limit of 2 idle connections.

Fixes #665
net/http uses copyBufPool to copy body.

var copyBufPool = sync.Pool{
	New: func() any {
		b := make([]byte, 32*1024)
		return &b
	},
}

The default buffer size is 4KiB, increasing to 32KiB improves throughput by 5-10%.

Note the req/seq stability improvement to almost 100%.

$ wrk http://127.0.0.1:3128 -d 10 -t 1 -c 200
Running 10s test @ http://127.0.0.1:3128
  1 threads and 200 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     6.25ms    1.11ms  24.05ms   82.07%
    Req/Sec    32.15k     1.29k   34.36k    85.00%
  319722 requests in 10.01s, 30.49MB read
  Socket errors: connect 0, read 41, write 0, timeout 0
Requests/sec:  31944.24
Transfer/sec:      3.05MB

$ wrk http://127.0.0.1:3128 -d 10 -t 1 -c 200
Running 10s test @ http://127.0.0.1:3128
  1 threads and 200 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     5.74ms    1.24ms  33.95ms   89.38%
    Req/Sec    35.13k     1.37k   35.90k    99.00%
  349432 requests in 10.01s, 33.32MB read
  Socket errors: connect 0, read 41, write 0, timeout 0
Requests/sec:  34912.41
Transfer/sec:      3.33MB
@mmatczuk mmatczuk merged commit f26d3cc into main Jan 30, 2024
@mmatczuk mmatczuk deleted the mmt/pool_config branch January 30, 2024 12:08
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