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

performance: slow than net/http with default setting #3234

Closed
hanjm opened this issue Dec 7, 2019 · 3 comments
Closed

performance: slow than net/http with default setting #3234

hanjm opened this issue Dec 7, 2019 · 3 comments

Comments

@hanjm
Copy link

hanjm commented Dec 7, 2019

https://github.com/plutov/benchmark-grpc-protobuf-vs-http-json is a benchmark repo about grpc-protobuf(Unary) vs http-json, it seems grpc-go slow than net/http with default setting in latest benchmark result at 2019.
i try to set InitialWindowSize=1<<30,InitialConnWindowSize=1<<30,WriteBufferSize=256 * 1024, ReadBufferSize=256 * 1024 both client and server, then grpc-go similar than net/http at 1 connection 1 concurrency regular scenario.

$ go test -bench . -benchmem -test.count 4
goos: darwin
goarch: amd64
BenchmarkGRPCProtobuf-8   	   10000	    109227 ns/op	    9829 B/op	     191 allocs/op
BenchmarkGRPCProtobuf-8   	   10000	    102425 ns/op	    9824 B/op	     191 allocs/op
BenchmarkGRPCProtobuf-8   	   10000	    101966 ns/op	    9823 B/op	     191 allocs/op
BenchmarkGRPCProtobuf-8   	   10000	    100819 ns/op	    9823 B/op	     191 allocs/op
BenchmarkHTTPJSON-8       	   10000	    103827 ns/op	    8904 B/op	     117 allocs/op
BenchmarkHTTPJSON-8       	   10000	    102093 ns/op	    8902 B/op	     117 allocs/op
BenchmarkHTTPJSON-8       	   10000	    100043 ns/op	    8903 B/op	     117 allocs/op
BenchmarkHTTPJSON-8       	   10000	    121196 ns/op	    8904 B/op	     117 allocs/op
PASS

related slow than net/http issue at 2015: #89 #108
related issue about window size adjust. #1043
related issue about buffer size adjust.#1569
related issue about performance. #586

@dfawley
Copy link
Member

dfawley commented Dec 19, 2019

@hanjm the numbers you are showing don't appear to be significantly slower. Can you explain more what the numbers mean and how you are interpreting them? Also, running more iterations may show different results, or more operations per iteration may be helpful in reducing variance.

@hanjm
Copy link
Author

hanjm commented Dec 20, 2019

hi @dfawley , as result of https://github.com/plutov/benchmark-grpc-protobuf-vs-http-json, with default transport settings, the conclusion is that

They are almost the same, HTTP+JSON is a bit faster and has less allocs/op.

Unary gRPC why slow than HTTP/1, it just counterintuitive and confusing, how to explain it?

@dfawley
Copy link
Member

dfawley commented Dec 20, 2019

Unary gRPC why slow than HTTP/1, it just counterintuitive and confusing, how to explain it?

I can't explain this without fully understanding how these particular benchmarks work. This is a bit of an apples-to-oranges comparison, regardless, since gRPC has more features than HTTP/1+JSON (e.g. bi-directional streaming, multiple streams over a single connection, flow control). These features do have some cost, although we expect it to be a small one.

If you're interested in looking more, we have a benchmark directory in gRPC-go that contains a binary capable of running benchmarks with various parameters, which is what we use for our testing. There are also regular benchmark results available through our website. This link will take you directly there: https://performance-dot-grpc-testing.appspot.com/explore?dashboard=5636470266134528.

@dfawley dfawley closed this as completed Dec 20, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants