- Notifications
You must be signed in to change notification settings - Fork35
Transfer 10Gbps http traffic over 1Gbps networks :)
License
valyala/httpteleport
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Teleports 10Gbps http traffic over 1Gbps networks.Built on top offastrpc.
httpteleport
may significantly reduce inter-server network bandwidth overheadand costs for the following cases:
- RTB servers.
- HTTP-based API servers (aka REST, JSON, JSON-RPC or HTTP-RPC servicesand microservices).
- Reverse proxies.
- Load balancers.
It just sends batched http requests and responses over a single compressedconnection. This solves the following issues:
- High network bandwidth usage
- High network packets rate
- A lot of open TCP connections
Unlikehttp pipelining,httpteleport
responses may be sent out-of-order.This resolveshead of line blocking issue.
httptp -standalone single-binary reverse proxy and load balancer basedon
httpteleport
.httptp
source code may be used as an exampleofhttpteleport
usage.
Q: Why
httpteleport
doesn't useHTTP/2.0?A: Because
http/2.0
has many features, which aren't used byhttpteleport
.More features complicate the code, make it more error-prone and may slowit down.Q: Why does
httpteleport
providefasthttp-based API instead of standardnet/http-based API?A: Because
httpteleport
is optimized for speed. So it have to usefasthttp
for http-related stuff to be fast.Q: Give me performance numbers.
A:
httpteleport
achieves 200K qps on a single CPU core in end-to-end test,where a client sends requests to a local server and the server sendsresponses back to the client:
$ GOMAXPROCS=1 go test -bench=. -benchmemgoos: linuxgoarch: amd64pkg: github.com/valyala/httpteleportBenchmarkEndToEndGetNoDelay1 300000 4346 ns/op 60.05 MB/s 0 B/op 0 allocs/opBenchmarkEndToEndGetNoDelay10 300000 4370 ns/op 59.71 MB/s 3 B/op 0 allocs/opBenchmarkEndToEndGetNoDelay100 300000 4406 ns/op 59.23 MB/s 6 B/op 0 allocs/opBenchmarkEndToEndGetNoDelay1000 300000 4457 ns/op 58.55 MB/s 24 B/op 0 allocs/opBenchmarkEndToEndGetNoDelay10K 300000 5868 ns/op 44.48 MB/s 178 B/op 1 allocs/opBenchmarkEndToEndGetDelay1ms 300000 4771 ns/op 54.70 MB/s 21 B/op 0 allocs/opBenchmarkEndToEndGetDelay2ms 200000 7943 ns/op 32.86 MB/s 31 B/op 0 allocs/opBenchmarkEndToEndGetDelay4ms 200000 7741 ns/op 33.71 MB/s 31 B/op 0 allocs/opBenchmarkEndToEndGetDelay8ms 200000 10580 ns/op 24.67 MB/s 26 B/op 0 allocs/opBenchmarkEndToEndGetDelay16ms 100000 16923 ns/op 15.42 MB/s 50 B/op 0 allocs/opBenchmarkEndToEndGetCompressNone 200000 7899 ns/op 33.04 MB/s 31 B/op 0 allocs/opBenchmarkEndToEndGetCompressFlate 100000 13257 ns/op 19.69 MB/s 129 B/op 0 allocs/opBenchmarkEndToEndGetCompressSnappy 200000 8158 ns/op 31.99 MB/s 40 B/op 0 allocs/opBenchmarkEndToEndGetTLSCompressNone 200000 8692 ns/op 30.02 MB/s 39 B/op 0 allocs/opBenchmarkEndToEndGetTLSCompressFlate 100000 13710 ns/op 19.04 MB/s 131 B/op 0 allocs/opBenchmarkEndToEndGetTLSCompressSnappy 200000 8480 ns/op 30.78 MB/s 42 B/op 0 allocs/opBenchmarkEndToEndGetPipeline1 300000 4673 ns/op 55.85 MB/s 0 B/op 0 allocs/opBenchmarkEndToEndGetPipeline10 300000 4610 ns/op 56.61 MB/s 3 B/op 0 allocs/opBenchmarkEndToEndGetPipeline100 300000 4576 ns/op 57.03 MB/s 6 B/op 0 allocs/opBenchmarkEndToEndGetPipeline1000 300000 4886 ns/op 53.41 MB/s 26 B/op 0 allocs/op