Skip to content

Commit 81fc968

Browse files
Add warning to readme
1 parent 7fdd526 commit 81fc968

1 file changed

Lines changed: 18 additions & 14 deletions

File tree

README.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
Fast HTTP implementation for Go.
66

7+
# fasthttp might not be for you!
8+
fasthttp was design for some high performance edge cases. **Unless** your server/client needs to handle **thousands of small to medium requests per seconds** and needs a consistent low millisecond response time fasthttp might not be for you. **For most cases `net/http` is much better** as it's easier to use and can handle more cases. For most cases you won't even notice the performance difference.
9+
10+
11+
## General info and links
12+
713
Currently fasthttp is successfully used by [VertaMedia](https://vertamedia.com/)
814
in a production serving up to 200K rps from more than 1.5M concurrent keep-alive
915
connections per physical server.
@@ -34,7 +40,7 @@ connections per physical server.
3440

3541
[FAQ](#faq)
3642

37-
# HTTP server performance comparison with [net/http](https://golang.org/pkg/net/http/)
43+
## HTTP server performance comparison with [net/http](https://golang.org/pkg/net/http/)
3844

3945
In short, fasthttp server is up to 10 times faster than net/http.
4046
Below are benchmark results.
@@ -95,7 +101,7 @@ BenchmarkServerGet10ReqPerConn10KClients-4 30000000 346 ns/
95101
BenchmarkServerGet100ReqPerConn10KClients-4 50000000 282 ns/op 0 B/op 0 allocs/op
96102
```
97103

98-
# HTTP client comparison with net/http
104+
## HTTP client comparison with net/http
99105

100106
In short, fasthttp client is up to 10 times faster than net/http.
101107
Below are benchmark results.
@@ -157,14 +163,14 @@ BenchmarkClientGetEndToEnd1000Inmemory-4 10000000 1316 ns/
157163
```
158164

159165

160-
# Install
166+
## Install
161167

162168
```
163169
go get -u github.com/valyala/fasthttp
164170
```
165171

166172

167-
# Switching from net/http to fasthttp
173+
## Switching from net/http to fasthttp
168174

169175
Unfortunately, fasthttp doesn't provide API identical to net/http.
170176
See the [FAQ](#faq) for details.
@@ -393,7 +399,7 @@ instead of [html/template](https://golang.org/pkg/html/template/).
393399
[expvarhandler](https://godoc.org/github.com/valyala/fasthttp/expvarhandler).
394400

395401

396-
# Performance optimization tips for multi-core systems
402+
## Performance optimization tips for multi-core systems
397403

398404
* Use [reuseport](https://godoc.org/github.com/valyala/fasthttp/reuseport) listener.
399405
* Run a separate server instance per CPU core with GOMAXPROCS=1.
@@ -403,7 +409,7 @@ instead of [html/template](https://golang.org/pkg/html/template/).
403409
* Use the latest version of Go as each version contains performance improvements.
404410

405411

406-
# Fasthttp best practices
412+
## Fasthttp best practices
407413

408414
* Do not allocate objects and `[]byte` buffers - just reuse them as much
409415
as possible. Fasthttp API design encourages this.
@@ -424,7 +430,7 @@ instead of [html/template](https://golang.org/pkg/html/template/).
424430
[html/template](https://golang.org/pkg/html/template/) in your webserver.
425431

426432

427-
# Tricks with `[]byte` buffers
433+
## Tricks with `[]byte` buffers
428434

429435
The following tricks are used by fasthttp. Use them in your code too.
430436

@@ -479,7 +485,7 @@ statusCode, body, err := fasthttp.Get(nil, "http://google.com/")
479485
uintBuf := fasthttp.AppendUint(nil, 1234)
480486
```
481487

482-
# Related projects
488+
## Related projects
483489

484490
* [fasthttp](https://github.com/fasthttp) - various useful
485491
helpers for projects based on fasthttp.
@@ -505,7 +511,7 @@ uintBuf := fasthttp.AppendUint(nil, 1234)
505511
* [Gearbox](https://github.com/gogearbox/gearbox) - :gear: gearbox is a web framework written in Go with a focus on high performance and memory optimization
506512

507513

508-
# FAQ
514+
## FAQ
509515

510516
* *Why creating yet another http package instead of optimizing net/http?*
511517

@@ -542,9 +548,10 @@ uintBuf := fasthttp.AppendUint(nil, 1234)
542548
* net/http supports [HTTP/2.0 starting from go1.6](https://http2.golang.org/).
543549
* net/http API is stable, while fasthttp API constantly evolves.
544550
* net/http handles more HTTP corner cases.
551+
* net/http can stream both request and response bodies
552+
* net/http can handle bigger bodies as it doesn't read the whole body into memory
545553
* net/http should contain less bugs, since it is used and tested by much
546554
wider audience.
547-
* net/http works on Go older than 1.5.
548555

549556
* *Why fasthttp API prefers returning `[]byte` instead of `string`?*
550557

@@ -555,10 +562,7 @@ uintBuf := fasthttp.AppendUint(nil, 1234)
555562

556563
* *Which GO versions are supported by fasthttp?*
557564

558-
Go1.5+. Older versions won't be supported, since their standard package
559-
[miss useful functions](https://github.com/valyala/fasthttp/issues/5).
560-
561-
**NOTE**: Go 1.9.7 is the oldest tested version. We recommend you to update as soon as you can. As of 1.11.3 we will drop 1.9.x support.
565+
Go 1.15.x. Older versions won't be supported.
562566

563567
* *Please provide real benchmark data and server information*
564568

0 commit comments

Comments
 (0)