You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Go http.Server currently uses a hard coded 4 KB buffer for the response writer. In some cases, developers of certain applications may prefer increasing the default 4 KB for higher throughput and better performance.
The performance with the default 4 KB buffer size:
go test -test.bench=".*" -benchmem -benchtime=5s
BenchmarkBigWrite-4 100000 79756 ns/op 37929 B/op 72 allocs/op
ok mytest/httpbuf 8.857s
BenchmarkBigWrite-4 100000 78570 ns/op 37948 B/op 72 allocs/op
ok mytest/httpbuf 8.665s
BenchmarkBigWrite-4 100000 79072 ns/op 37876 B/op 72 allocs/op
ok mytest/httpbuf 8.718s
The performance with a 10 KB buffer size:
go test -test.bench=".*" -benchmem -benchtime=5s
BenchmarkBigWrite-4 100000 69645 ns/op 39890 B/op 73 allocs/op
ok mytest/httpbuf 7.692s
BenchmarkBigWrite-4 100000 69816 ns/op 39961 B/op 73 allocs/op
ok mytest/httpbuf 7.702s
BenchmarkBigWrite-4 100000 67768 ns/op 39856 B/op 73 allocs/op
ok mytest/httpbuf 7.516s
Proposed solution:
Add a configurable WriteBufferSize option to the http.Server struct, which then the HTTP server will use when set instead of the hard coded 4 << 10 value.
I have recently opened a pull request that possibly addresses this #68143
The text was updated successfully, but these errors were encountered:
Proposal Details
The Go
http.Server
currently uses a hard coded 4 KB buffer for the response writer. In some cases, developers of certain applications may prefer increasing the default 4 KB for higher throughput and better performance.This has been discussed previously at #13870 and at https://groups.google.com/g/golang-dev/c/OuFtcKEyGrg
The performance with the default 4 KB buffer size:
The performance with a 10 KB buffer size:
Proposed solution:
Add a configurable
WriteBufferSize
option to thehttp.Server
struct, which then the HTTP server will use when set instead of the hard coded4 << 10
value.I have recently opened a pull request that possibly addresses this #68143
The text was updated successfully, but these errors were encountered: