https://github.com/kingluo/etcd-benchmark
etcd http/grpc performance testing
https://github.com/kingluo/etcd-benchmark
etcd etcdv3 grpc http
Last synced: about 1 year ago
JSON representation
etcd http/grpc performance testing
- Host: GitHub
- URL: https://github.com/kingluo/etcd-benchmark
- Owner: kingluo
- License: bsd-3-clause
- Created: 2023-05-07T07:29:08.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-16T05:37:27.000Z (almost 3 years ago)
- Last Synced: 2025-01-28T02:27:26.394Z (about 1 year ago)
- Topics: etcd, etcdv3, grpc, http
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# etcd-benchmark
etcd http/grpc performance testing
## background
What is the difference in the efficiency of accessing etcd with http and grpc respectively?
We use below client programs to do the test:
1. http [go-http](https://pkg.go.dev/net/http#Client), access etcd grpc gateway, http keepalive enabled
2. grpc [go-etcd](https://pkg.go.dev/go.etcd.io/etcd/client/v3)
## test
```bash
# http put
go run http.go -c 10 -n 8000 -host http://httpbin.local:2379 -put
# grpc put
go run grpc.go -c 10 -n 8000 -host http://httpbin.local:2379 -put
# you could watch the connections to etcd
watch -n 3 "ss -tnp '( dport = :2379 )' | sort -k6"
# http watch
# in terminal-1
go run http.go -c 10 -n 8000 -host http://httpbin.local:2379 -watch
# in terminal-2, raise traffic to watch
go run grpc.go -c 10 -n 8000 -host http://httpbin.local:2379 -put
# grpc watch
# in terminal-1
go run grpc.go -c 10 -n 8000 -host http://httpbin.local:2379 -watch
# in terminal-2, raise traffic to watch
go run grpc.go -c 10 -n 8000 -host http://httpbin.local:2379 -put
```

* watch performance is almost the same,
because http uses only one tcp connection and chunked streaming for receiving watch events.
* put performance, grpc is about `13%` better than http, and the cpu of etcd server is smaller than grpc client.
* http uses multiple tcp connections, because http/1.1 cannot multiplex requests
* http has bigger size of packets than grpc (http/2)
* etcd uses grpc-gateway to bridge the traffic between http and grpc internally