Fast HTTP package for Go. Tuned for high performance. Zero memory allocations in hot paths. Up to 10x faster than net/http

Gabriel Pérez S 996610f021 Schema changes detection with HostClient 1 year ago
examples 2cc8e6be6d go fmt ./... 1 month ago
expvarhandler b43280dfe8 expvarhandler: properly generate json output when regexp filter is present 2 years ago
fasthttpadaptor 930362b9f8 go vet fix 2 years ago
fasthttpproxy 7529e6b2e5 Add SOCKS5 dialer 1 month ago
fasthttputil 2cc8e6be6d go fmt ./... 1 month ago
pprofhandler 33b80a5951 Add support for named profiles like heap, goroutine, threadcreate, allocs, block, and mutex. 2 weeks ago
reuseport 7ec2b18772 Remove race condition from test 3 weeks ago
stackless 110dea26f8 ci, reuseport, writer: update travis config and goimports -w on whole project 2 months ago
testdata d53df67945 Fix Content-Type bug in FS 3 weeks ago
.gitignore 55ffa05fae Ignore *.fasthttp.gz files 2 years ago
.travis.yml 3d4ce5b57c Fix data race errors 3 weeks ago
LICENSE 57b1f46d15 Update LICENSE 1 month ago 351f874e5e Fix small typo in readme 1 month ago
TODO 22c9594090 Added PipelineClient for issuing pipelined requests to the server 2 years ago
args.go d4f0cf56d8 Remove fasthttp.ByteBuffer 2 weeks ago
args_test.go d4f0cf56d8 Remove fasthttp.ByteBuffer 2 weeks ago
args_timing_test.go 91f896309a Added benchmark for Args.Peek() 2 years ago
bytesconv.go 5c41b44ca7 use proper "Deprecated" comment format 1 month ago
bytesconv_32.go d32baf2c3a Updated test matrix in .travis.yml according to 2 years ago
bytesconv_32_test.go d32baf2c3a Updated test matrix in .travis.yml according to 2 years ago
bytesconv_64.go d32baf2c3a Updated test matrix in .travis.yml according to 2 years ago
bytesconv_64_test.go d32baf2c3a Updated test matrix in .travis.yml according to 2 years ago
bytesconv_test.go d4f0cf56d8 Remove fasthttp.ByteBuffer 2 weeks ago
bytesconv_timing_test.go d4f0cf56d8 Remove fasthttp.ByteBuffer 2 weeks ago
client.go 996610f021 Schema changes detection with HostClient 3 days ago
client_example_test.go 215f1d2caf Added an example for HostClient 2 years ago
client_test.go 996610f021 Schema changes detection with HostClient 3 days ago
client_timing_test.go 881ac52b00 Added support for multiple concurrent connections to server in PipelineClient 2 years ago
coarseTime.go ef10ed05a3 deprecate CoarseTime and replace it with a shortcut implementation 2 months ago
coarseTime_test.go 32c72cde80 Export CoarseTimeNow and clarify that RequestCtx.Time() and RequestCtx.ConnTime() return time truncated to a second 1 year ago
compress.go d4f0cf56d8 Remove fasthttp.ByteBuffer 2 weeks ago
compress_test.go 30e92af08f Limit heap memory usage when compressing high number of concurrent responses 1 year ago
cookie.go dbc9965d33 Adds support for max-age cookie value. Fixes #184 (#412) 1 month ago
cookie_test.go dbc9965d33 Adds support for max-age cookie value. Fixes #184 (#412) 1 month ago
cookie_timing_test.go 236d4bd461 Added Cookie.ParseBytes to be consistent with Args 2 years ago
doc.go 5f6439b6df Remove wrong documentation 1 month ago
fs.go d4f0cf56d8 Remove fasthttp.ByteBuffer 2 weeks ago
fs_example_test.go e0568fa3fb Fixed a typo 2 years ago
fs_handler_example_test.go f8ff9270f2 Added an example for FS 2 years ago
fs_test.go d53df67945 Fix Content-Type bug in FS 3 weeks ago
go.mod 4087354082 Support Go modules 2 weeks ago
go.sum 4087354082 Support Go modules 2 weeks ago
header.go 4dfc12997e Add RequestHeader.RawHeaders() 1 week ago
header_regression_test.go 69a05ffcaf Issue #28: do not set default Content-Type for empty response 2 years ago
header_test.go 63ea2d380f Remove invalid test introduced in #378 1 week ago
header_timing_test.go d4f0cf56d8 Remove fasthttp.ByteBuffer 2 weeks ago
http.go 996610f021 Schema changes detection with HostClient 3 days ago
http_test.go d459e257bf Use form headers in WriteMultipartForm 1 week ago
lbclient.go f24d00fcc6 A lot of typo fixes 1 year ago
lbclient_example_test.go a965b01816 Added an example for LBClient 2 years ago
nocopy.go 9f43aa1601 Do not expose noCopy.Lock 2 years ago
peripconn.go 57cbe65ddc scalability improvement: use per-server peripconn pool 2 years ago
peripconn_test.go 3eaecd9c6c Added ability to limit the number of concurrent client connections per ip 3 years ago
requestctx_setbodystreamwriter_example_test.go 05949704db Issue #78: Added an example for RequestCtx.SetBodyStreamWriter 2 years ago
server.go afcef43292 Add RequestCtx.Conn() method 3 days ago
server_example_test.go 6a8707cd8d Import fasthttp in server examples 2 years ago
server_test.go 573be81328 Hopefully fix TestShutdownReuse flakiness 3 days ago
server_timing_test.go fc109d6887 Added a benchmark for RequestCtx.Redirect 1 year ago
ssl-cert-snakeoil.key 2cb5ae6a34 Added missing snakeoil ssl certificates for client tests 2 years ago
ssl-cert-snakeoil.pem 2cb5ae6a34 Added missing snakeoil ssl certificates for client tests 2 years ago
status.go 8edddf21b9 add missing http status codes (#140) 2 years ago
stream.go 886e541160 Removed 'recover-from-panic' band-aids. 2 years ago
stream_test.go 80af8b2b97 Simplified PipeConns - now they properly handle the case when reader side is closed 2 years ago
stream_timing_test.go ce9d1d2224 Use fasthttp.PipeConns instead of io.Pipe in StreamReader 2 years ago
strings.go dbc9965d33 Adds support for max-age cookie value. Fixes #184 (#412) 1 month ago
tcpdialer.go 44f08d5588 Issue #196: avoid returning (nil, nil) from fasthttp.Dial* 1 year ago
timer.go f36b47782a removed memory allocations from tryDial. This should improve performance for non-keepalive connections 2 years ago
uri.go 4a16377d6e Merge pull request #303 from chebyrash/master 2 months ago
uri_test.go 50bdd6c77c Fix appendQuotedPath to include all allowed characters 1 month ago
uri_timing_test.go f1f78f0828 Hide Request.URI and Request.PostArgs behind accessors, which automatically call parse URI and PostArgs on first access 2 years ago
uri_unix.go 92ec2638f3 go fmt 2 years ago
uri_windows.go 92ec2638f3 go fmt 2 years ago
uri_windows_test.go 5e1bdcae2d Issue #86: Fixed leading slash on Windows 2 years ago
userdata.go 0d43464f64 Renamed unsafeBytes2Str to b2s 2 years ago
userdata_test.go eafcb74ce5 Call Close on user values stored via RequestCtx.SetUserValue if these values implement io.Closer 2 years ago
userdata_timing_test.go b00a213a93 Moved ctx.UserValue from standard map to custom userData. This should improve its' performance for common case when ctx contains up to 10 user values 2 years ago
workerpool.go 8dfc881b9e Added Server.nextProtos 1 week ago
workerpool_test.go c88d0992b4 vendor ConnState type in fasthttp package 1 month ago

Build Status GoDoc Go Report


Fast HTTP implementation for Go.

Currently fasthttp is successfully used by VertaMedia in a production serving up to 200K rps from more than 1.5M concurrent keep-alive connections per physical server.

TechEmpower Benchmark round 12 results

Server Benchmarks

Client Benchmarks



Examples from docs

Code examples

Awesome fasthttp tools

Switching from net/http to fasthttp

Fasthttp best practices

Tricks with byte buffers

Related projects


HTTP server performance comparison with net/http

In short, fasthttp server is up to 10 times faster than net/http. Below are benchmark results.


net/http server:

$ GOMAXPROCS=1 go test -bench=NetHTTPServerGet -benchmem -benchtime=10s
BenchmarkNetHTTPServerGet1ReqPerConn                	 1000000	     12052 ns/op	    2297 B/op	      29 allocs/op
BenchmarkNetHTTPServerGet2ReqPerConn                	 1000000	     12278 ns/op	    2327 B/op	      24 allocs/op
BenchmarkNetHTTPServerGet10ReqPerConn               	 2000000	      8903 ns/op	    2112 B/op	      19 allocs/op
BenchmarkNetHTTPServerGet10KReqPerConn              	 2000000	      8451 ns/op	    2058 B/op	      18 allocs/op
BenchmarkNetHTTPServerGet1ReqPerConn10KClients      	  500000	     26733 ns/op	    3229 B/op	      29 allocs/op
BenchmarkNetHTTPServerGet2ReqPerConn10KClients      	 1000000	     23351 ns/op	    3211 B/op	      24 allocs/op
BenchmarkNetHTTPServerGet10ReqPerConn10KClients     	 1000000	     13390 ns/op	    2483 B/op	      19 allocs/op
BenchmarkNetHTTPServerGet100ReqPerConn10KClients    	 1000000	     13484 ns/op	    2171 B/op	      18 allocs/op

fasthttp server:

$ GOMAXPROCS=1 go test -bench=kServerGet -benchmem -benchtime=10s
BenchmarkServerGet1ReqPerConn                       	10000000	      1559 ns/op	       0 B/op	       0 allocs/op
BenchmarkServerGet2ReqPerConn                       	10000000	      1248 ns/op	       0 B/op	       0 allocs/op
BenchmarkServerGet10ReqPerConn                      	20000000	       797 ns/op	       0 B/op	       0 allocs/op
BenchmarkServerGet10KReqPerConn                     	20000000	       716 ns/op	       0 B/op	       0 allocs/op
BenchmarkServerGet1ReqPerConn10KClients             	10000000	      1974 ns/op	       0 B/op	       0 allocs/op
BenchmarkServerGet2ReqPerConn10KClients             	10000000	      1352 ns/op	       0 B/op	       0 allocs/op
BenchmarkServerGet10ReqPerConn10KClients            	20000000	       789 ns/op	       2 B/op	       0 allocs/op
BenchmarkServerGet100ReqPerConn10KClients           	20000000	       604 ns/op	       0 B/op	       0 allocs/op


net/http server:

$ GOMAXPROCS=4 go test -bench=NetHTTPServerGet -benchmem -benchtime=10s
BenchmarkNetHTTPServerGet1ReqPerConn-4                  	 3000000	      4529 ns/op	    2389 B/op	      29 allocs/op
BenchmarkNetHTTPServerGet2ReqPerConn-4                  	 5000000	      3896 ns/op	    2418 B/op	      24 allocs/op
BenchmarkNetHTTPServerGet10ReqPerConn-4                 	 5000000	      3145 ns/op	    2160 B/op	      19 allocs/op
BenchmarkNetHTTPServerGet10KReqPerConn-4                	 5000000	      3054 ns/op	    2065 B/op	      18 allocs/op
BenchmarkNetHTTPServerGet1ReqPerConn10KClients-4        	 1000000	     10321 ns/op	    3710 B/op	      30 allocs/op
BenchmarkNetHTTPServerGet2ReqPerConn10KClients-4        	 2000000	      7556 ns/op	    3296 B/op	      24 allocs/op
BenchmarkNetHTTPServerGet10ReqPerConn10KClients-4       	 5000000	      3905 ns/op	    2349 B/op	      19 allocs/op
BenchmarkNetHTTPServerGet100ReqPerConn10KClients-4      	 5000000	      3435 ns/op	    2130 B/op	      18 allocs/op

fasthttp server:

$ GOMAXPROCS=4 go test -bench=kServerGet -benchmem -benchtime=10s
BenchmarkServerGet1ReqPerConn-4                         	10000000	      1141 ns/op	       0 B/op	       0 allocs/op
BenchmarkServerGet2ReqPerConn-4                         	20000000	       707 ns/op	       0 B/op	       0 allocs/op
BenchmarkServerGet10ReqPerConn-4                        	30000000	       341 ns/op	       0 B/op	       0 allocs/op
BenchmarkServerGet10KReqPerConn-4                       	50000000	       310 ns/op	       0 B/op	       0 allocs/op
BenchmarkServerGet1ReqPerConn10KClients-4               	10000000	      1119 ns/op	       0 B/op	       0 allocs/op
BenchmarkServerGet2ReqPerConn10KClients-4               	20000000	       644 ns/op	       0 B/op	       0 allocs/op
BenchmarkServerGet10ReqPerConn10KClients-4              	30000000	       346 ns/op	       0 B/op	       0 allocs/op
BenchmarkServerGet100ReqPerConn10KClients-4             	50000000	       282 ns/op	       0 B/op	       0 allocs/op

HTTP client comparison with net/http

In short, fasthttp client is up to 10 times faster than net/http. Below are benchmark results.


net/http client:

$ GOMAXPROCS=1 go test -bench='HTTPClient(Do|GetEndToEnd)' -benchmem -benchtime=10s
BenchmarkNetHTTPClientDoFastServer                  	 1000000	     12567 ns/op	    2616 B/op	      35 allocs/op
BenchmarkNetHTTPClientGetEndToEnd1TCP               	  200000	     67030 ns/op	    5028 B/op	      56 allocs/op
BenchmarkNetHTTPClientGetEndToEnd10TCP              	  300000	     51098 ns/op	    5031 B/op	      56 allocs/op
BenchmarkNetHTTPClientGetEndToEnd100TCP             	  300000	     45096 ns/op	    5026 B/op	      55 allocs/op
BenchmarkNetHTTPClientGetEndToEnd1Inmemory          	  500000	     24779 ns/op	    5035 B/op	      57 allocs/op
BenchmarkNetHTTPClientGetEndToEnd10Inmemory         	 1000000	     26425 ns/op	    5035 B/op	      57 allocs/op
BenchmarkNetHTTPClientGetEndToEnd100Inmemory        	  500000	     28515 ns/op	    5045 B/op	      57 allocs/op
BenchmarkNetHTTPClientGetEndToEnd1000Inmemory       	  500000	     39511 ns/op	    5096 B/op	      56 allocs/op

fasthttp client:

$ GOMAXPROCS=1 go test -bench='kClient(Do|GetEndToEnd)' -benchmem -benchtime=10s
BenchmarkClientDoFastServer                         	20000000	       865 ns/op	       0 B/op	       0 allocs/op
BenchmarkClientGetEndToEnd1TCP                      	 1000000	     18711 ns/op	       0 B/op	       0 allocs/op
BenchmarkClientGetEndToEnd10TCP                     	 1000000	     14664 ns/op	       0 B/op	       0 allocs/op
BenchmarkClientGetEndToEnd100TCP                    	 1000000	     14043 ns/op	       1 B/op	       0 allocs/op
BenchmarkClientGetEndToEnd1Inmemory                 	 5000000	      3965 ns/op	       0 B/op	       0 allocs/op
BenchmarkClientGetEndToEnd10Inmemory                	 3000000	      4060 ns/op	       0 B/op	       0 allocs/op
BenchmarkClientGetEndToEnd100Inmemory               	 5000000	      3396 ns/op	       0 B/op	       0 allocs/op
BenchmarkClientGetEndToEnd1000Inmemory              	 5000000	      3306 ns/op	       2 B/op	       0 allocs/op


net/http client:

$ GOMAXPROCS=4 go test -bench='HTTPClient(Do|GetEndToEnd)' -benchmem -benchtime=10s
BenchmarkNetHTTPClientDoFastServer-4                    	 2000000	      8774 ns/op	    2619 B/op	      35 allocs/op
BenchmarkNetHTTPClientGetEndToEnd1TCP-4                 	  500000	     22951 ns/op	    5047 B/op	      56 allocs/op
BenchmarkNetHTTPClientGetEndToEnd10TCP-4                	 1000000	     19182 ns/op	    5037 B/op	      55 allocs/op
BenchmarkNetHTTPClientGetEndToEnd100TCP-4               	 1000000	     16535 ns/op	    5031 B/op	      55 allocs/op
BenchmarkNetHTTPClientGetEndToEnd1Inmemory-4            	 1000000	     14495 ns/op	    5038 B/op	      56 allocs/op
BenchmarkNetHTTPClientGetEndToEnd10Inmemory-4           	 1000000	     10237 ns/op	    5034 B/op	      56 allocs/op
BenchmarkNetHTTPClientGetEndToEnd100Inmemory-4          	 1000000	     10125 ns/op	    5045 B/op	      56 allocs/op
BenchmarkNetHTTPClientGetEndToEnd1000Inmemory-4         	 1000000	     11132 ns/op	    5136 B/op	      56 allocs/op

fasthttp client:

$ GOMAXPROCS=4 go test -bench='kClient(Do|GetEndToEnd)' -benchmem -benchtime=10s
BenchmarkClientDoFastServer-4                           	50000000	       397 ns/op	       0 B/op	       0 allocs/op
BenchmarkClientGetEndToEnd1TCP-4                        	 2000000	      7388 ns/op	       0 B/op	       0 allocs/op
BenchmarkClientGetEndToEnd10TCP-4                       	 2000000	      6689 ns/op	       0 B/op	       0 allocs/op
BenchmarkClientGetEndToEnd100TCP-4                      	 3000000	      4927 ns/op	       1 B/op	       0 allocs/op
BenchmarkClientGetEndToEnd1Inmemory-4                   	10000000	      1604 ns/op	       0 B/op	       0 allocs/op
BenchmarkClientGetEndToEnd10Inmemory-4                  	10000000	      1458 ns/op	       0 B/op	       0 allocs/op
BenchmarkClientGetEndToEnd100Inmemory-4                 	10000000	      1329 ns/op	       0 B/op	       0 allocs/op
BenchmarkClientGetEndToEnd1000Inmemory-4                	10000000	      1316 ns/op	       5 B/op	       0 allocs/op


go get -u

Switching from net/http to fasthttp

Unfortunately, fasthttp doesn't provide API identical to net/http. See the FAQ for details. There is net/http -> fasthttp handler converter, but it is better to write fasthttp request handlers by hand in order to use all of the fasthttp advantages (especially high performance :) ).

Important points:

  type MyHandler struct {
  	foobar string

  // request handler in net/http style, i.e. method bound to MyHandler struct.
  func (h *MyHandler) HandleFastHTTP(ctx *fasthttp.RequestCtx) {
  	// notice that we may access MyHandler properties here - see h.foobar.
  	fmt.Fprintf(ctx, "Hello, world! Requested path is %q. Foobar is %q",
  		ctx.Path(), h.foobar)

  // request handler in fasthttp style, i.e. just plain function.
  func fastHTTPHandler(ctx *fasthttp.RequestCtx) {
  	fmt.Fprintf(ctx, "Hi there! RequestURI is %q", ctx.RequestURI())

  // pass bound struct method to fasthttp
  myHandler := &MyHandler{
  	foobar: "foobar",
  fasthttp.ListenAndServe(":8080", myHandler.HandleFastHTTP)

  // pass plain function to fasthttp
  fasthttp.ListenAndServe(":8081", fastHTTPHandler)
  • The RequestHandler accepts only one argument - RequestCtx. It contains all the functionality required for http request processing and response writing. Below is an example of a simple request handler conversion from net/http to fasthttp.
  // net/http request handler
  requestHandler := func(w http.ResponseWriter, r *http.Request) {
  	switch r.URL.Path {
  	case "/foo":
  		fooHandler(w, r)
  	case "/bar":
  		barHandler(w, r)
  		http.Error(w, "Unsupported path", http.StatusNotFound)
  // the corresponding fasthttp request handler
  requestHandler := func(ctx *fasthttp.RequestCtx) {
  	switch string(ctx.Path()) {
  	case "/foo":
  	case "/bar":
  		ctx.Error("Unsupported path", fasthttp.StatusNotFound)
  • Fasthttp allows setting response headers and writing response body in an arbitrary order. There is no 'headers first, then body' restriction like in net/http. The following code is valid for fasthttp:
  requestHandler := func(ctx *fasthttp.RequestCtx) {
  	// set some headers and status code first

  	// then write the first part of body
  	fmt.Fprintf(ctx, "this is the first part of body\n")

  	// then set more headers
  	ctx.Response.Header.Set("Foo-Bar", "baz")

  	// then write more body
  	fmt.Fprintf(ctx, "this is the second part of body\n")

  	// then override already written body
  	ctx.SetBody([]byte("this is completely new body contents"))

  	// then update status code

  	// basically, anything may be updated many times before
  	// returning from RequestHandler.
  	// Unlike net/http fasthttp doesn't put response to the wire until
  	// returning from RequestHandler.

Net/http code with simple ServeMux is trivially converted to fasthttp code:

  // net/http code

  m := &http.ServeMux{}
  m.HandleFunc("/foo", fooHandlerFunc)
  m.HandleFunc("/bar", barHandlerFunc)
  m.Handle("/baz", bazHandler)

  http.ListenAndServe(":80", m)
  // the corresponding fasthttp code
  m := func(ctx *fasthttp.RequestCtx) {
  	switch string(ctx.Path()) {
  	case "/foo":
  	case "/bar":
  	case "/baz":
  		ctx.Error("not found", fasthttp.StatusNotFound)

  fasthttp.ListenAndServe(":80", m)

Use this brilliant tool - race detector - for detecting and eliminating data races in your program. If you detected data race related to fasthttp in your program, then there is high probability you forgot calling TimeoutError before returning from RequestHandler.

Performance optimization tips for multi-core systems

  • Use reuseport listener.
  • Run a separate server instance per CPU core with GOMAXPROCS=1.
  • Pin each server instance to a separate CPU core using taskset.
  • Ensure the interrupts of multiqueue network card are evenly distributed between CPU cores. See this article for details.
  • Use Go 1.6 as it provides some considerable performance improvements.

Fasthttp best practices

  • Do not allocate objects and []byte buffers - just reuse them as much as possible. Fasthttp API design encourages this.
  • sync.Pool is your best friend.
  • Profile your program in production. go tool pprof --alloc_objects your-program mem.pprof usually gives better insights for optimization opportunities than go tool pprof your-program cpu.pprof.
  • Write tests and benchmarks for hot paths.
  • Avoid conversion between []byte and string, since this may result in memory allocation+copy. Fasthttp API provides functions for both []byte and string - use these functions instead of converting manually between []byte and string. There are some exceptions - see this wiki page for more details.
  • Verify your tests and production code under race detector on a regular basis.
  • Prefer quicktemplate instead of html/template in your webserver.

Tricks with []byte buffers

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

  • Standard Go functions accept nil buffers ```go var ( // both buffers are uninitialized dst []byte src []byte ) dst = append(dst, src...) // is legal if dst is nil and/or src is nil copy(dst, src) // is legal if dst is nil and/or src is nil (string(src) == "") // is true if src is nil (len(src) == 0) // is true if src is nil src = src[:0] // works like a charm with nil src

// this for loop doesn't panic if src is nil for i, ch := range src { doSomething(i, ch) }

So throw away nil checks for `[]byte` buffers from you code. For example,
srcLen := 0
if src != nil {
	srcLen = len(src)


srcLen := len(src)
  • String may be appended to []byte buffer with append

    dst = append(dst, "foobar"...)
  • []byte buffer may be extended to its' capacity.

    buf := make([]byte, 100)
    a := buf[:10]  // len(a) == 10, cap(a) == 100.
    b := a[:100]  // is valid, since cap(a) == 100.
  • All fasthttp functions accept nil []byte buffer

    statusCode, body, err := fasthttp.Get(nil, "")
    uintBuf := fasthttp.AppendUint(nil, 1234)

Related projects

  • fasthttp - various useful helpers for projects based on fasthttp.
  • fasthttp-routing - fast and powerful routing package for fasthttp servers.
  • fasthttprouter - a high performance fasthttp request router that scales well.
  • gramework - a web framework made by one of fasthttp maintainers
  • lu - a high performance go middleware web framework which is based on fasthttp.
  • websocket - Gorilla-based websocket implementation for fasthttp.
  • fasthttpsession - a fast and powerful session package for fasthttp servers.
  • atreugo - Micro-framework to make simple the use of routing and middlewares.


  • Why creating yet another http package instead of optimizing net/http?

Because net/http API limits many optimization opportunities. For example:

  • net/http Request object lifetime isn't limited by request handler execution time. So the server must create a new request object per each request instead of reusing existing objects like fasthttp does.
  • net/http headers are stored in a map[string][]string. So the server must parse all the headers, convert them from []byte to string and put them into the map before calling user-provided request handler. This all requires unnecessary memory allocations avoided by fasthttp.
  • net/http client API requires creating a new response object per each request.

  • Why fasthttp API is incompatible with net/http?

Because net/http API limits many optimization opportunities. See the answer above for more details. Also certain net/http API parts are suboptimal for use:

HTTP/2.0 support is in progress. WebSockets has been done already. Third parties also may use RequestCtx.Hijack for implementing these goodies.

  • Are there known net/http advantages comparing to fasthttp?


  • net/http supports HTTP/2.0 starting from go1.6.
  • net/http API is stable, while fasthttp API constantly evolves.
  • net/http handles more HTTP corner cases.
  • net/http should contain less bugs, since it is used and tested by much wider audience.
  • net/http works on Go older than 1.5.

  • Why fasthttp API prefers returning []byte instead of string?

Because []byte to string conversion isn't free - it requires memory allocation and copy. Feel free wrapping returned []byte result into string() if you prefer working with strings instead of byte slices. But be aware that this has non-zero overhead.

  • Which GO versions are supported by fasthttp?

Go1.5+. Older versions won't be supported, since their standard package miss useful functions.

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.

  • Please provide real benchmark data and server information

See this issue.

  • Are there plans to add request routing to fasthttp?

There are no plans to add request routing into fasthttp. Use third-party routers and web frameworks with fasthttp support:

* [fasthttp-routing](
* [fasthttprouter](
* [gramework](
* [lu](
* [atreugo](

See also this issue for more info.

  • I detected data race in fasthttp!

Cool! File a bug. But before doing this check the following in your code:

  • Make sure there are no references to RequestCtx or to its' members after returning from RequestHandler.
  • Make sure you call TimeoutError before returning from RequestHandler if there are references to RequestCtx or to its' members, which may be accessed by other goroutines.

  • I didn't find an answer for my question here

Try exploring these questions.