Documentation
¶
Overview ¶
Package main is ./example/concurrency with one change: every worker builds its own tls-client instead of sharing one. All workers still request the same host, so the two programs are directly comparable.
What changes with a client per worker:
- Each client keeps its own connection pool, so the workers cannot share a connection. The dial counter below shows one dial per worker rather than one for the whole run, which means one TLS handshake per worker too.
- Each client keeps its own TLS session cache, so nothing is resumed across workers.
- The fixed cost of a client is paid N times. The line after the clients are built reports what that costs on the heap.
Sharing one client is the better default for this workload. Build a client per worker when the workers need to differ - a proxy or profile each, say - not to get concurrency, which a single client already handles.
Each worker decodes the response and then waits a couple of seconds, so the target sees a trickle of traffic rather than a load test.
Run:
go run ./example/client_per_worker go run ./example/client_per_worker -goroutines 8 -requests 10 go run ./example/client_per_worker -memprofile heap.out
Inspect a heap profile with: go tool pprof heap.out