Library / SDK
valyala/fasthttp avatar
valyala/fasthttp

fasthttp: zero-allocation HTTP for Go, what the benchmarks show and why net/http is still the default advice

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

23,514 stars1,893 forksGoMIT

At a glance

What is it?
fasthttp is a MIT-licensed Go HTTP server and client tuned for allocation-free hot paths. Its own README tells most teams to stay on net/http, and its published numbers explain exactly when that advice flips.
Who is it for?
Choose fasthttp only if your Go service handles thousands of small to medium requests per second and needs steady low millisecond latency, and you accept an API that is not identical to net/http. Stay on net/http if you want the easier, more general package, because the project itself says the difference goes unnoticed in most cases.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository received new commits within the last day.
What is it written in?
Mainly Go, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • valyala/fasthttp23,514 ★ · +43
Star history
Repository2026-09-212026-11-15
valyala/fasthttp23.5k23.5k

43 Stars in the last 55 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

The README opens by telling most people not to use it

The first section of the README is titled "fasthttp might not be for you!" and it is specific about who it is for. fasthttp was designed for high performance edge cases. Unless your server or client needs to handle thousands of small to medium requests per second and needs a consistent low millisecond response time, it says fasthttp might not be for you. For most cases net/http is described as much better because it is easier to use and handles more cases, and in most cases you will not even notice the performance difference.

That statement sets the cost side of the trade. You give up net/http's generality and familiar API in exchange for throughput under load. If your service sits behind a slow database call or serves a few hundred requests per second, the saving is small and the switching effort is real. The decision is about your request rate and latency target, not about what feels modern.

Server benchmarks: 36 allocations per request against none

The README publishes `go test` benchmark output on an Intel Xeon CPU at 2.20GHz, run with `-benchmem -benchtime=10s`. The command pattern for the net/http server is:

code
$ GOMAXPROCS=1 go test -bench=NetHTTPServerGet -benchmem -benchtime=10s

With one connection per request and GOMAXPROCS=1, net/http took 15327 ns/op with 3258 B/op and 36 allocs/op, while fasthttp took 2733 ns/op with 0 B/op and 0 allocs/op. At GOMAXPROCS=4 with 10,000 requests per connection, net/http reported 2179 ns/op and fasthttp 451.4 ns/op. The README summarizes this as the server being up to 6 times faster than net/http.

Two cautions follow. These are the author's figures from one machine type, and a plain GET handler is the measured workload. Your handler, middleware and network will move the result, so treat the table as a reason to test, not as a forecast.

Client benchmarks show the gap is smaller and not always zero allocation

The client comparison uses the benchmarks matching `HTTPClient(Do|GetEndToEnd)` for net/http and `kClient(Do|GetEndToEnd)` for fasthttp. At GOMAXPROCS=1, the net/http `GetEndToEnd1TCP` case took 55619 ns/op with 70 allocs/op, and the fasthttp equivalent took 26558 ns/op with 0 allocs/op. At GOMAXPROCS=4 the same case measured 16175 ns/op for net/http against 8143 ns/op for fasthttp.

The README's summary is that the client is up to 4 times faster, lower than the 6 times it claims for the server. Allocation is also not literally zero everywhere: the 100 TCP connection cases show 3 and 4 B/op, though still 0 allocs/op. The repository description says up to 10x faster than net/http, but the README's own server and client numbers top out at 6x and 4x, so quote the README figures when you justify a migration.

Production evidence is one named deployment and one public benchmark round

The README states that fasthttp is used by VertaMedia in production, serving up to 200K requests per second from more than 1.5M concurrent keep-alive connections per physical server. It also links TechEmpower Benchmark round 23 plaintext results. Those are the only external data points in the README text, and neither tells you how your workload behaves.

The release history shows continuing activity: v1.75.0 on 2026-10-05, v1.76.0 on 2026-10-19 and v1.77.0 on 2026-10-26, with the last push on 2026-11-02. Releases come roughly every one to two weeks in that window, and each one can change behavior, so pin the version in go.mod and read release notes before upgrading a service.

Switching is a rewrite of handlers because the API is not net/http's

The section titled "Switching from net/http to fasthttp" begins with an admission: fasthttp does not provide an API identical to net/http. The code layout reflects this. Server and client logic sit in files such as client.go, header.go, cookie.go and args.go inside the root package, while the standard `http.Handler` signature is not what you write.

For code that already speaks net/http, the repository ships a `fasthttpadaptor` package. There are also `fasthttpproxy` for proxy-aware dialing, `fasthttputil` for helpers and `expvarhandler` for exposing expvar. The consequence is that middleware, routers and libraries written against net/http cannot be dropped in unchanged. Budget for rewriting handler code and for finding fasthttp-aware replacements for each library you depend on.

Module requirements: Go 1.26.0 and six direct dependencies

The install command is a single line:

code
go get -u github.com/valyala/fasthttp

The go.mod declares `go 1.26.0`, so older toolchains will refuse the module as it stands. The direct requirements are github.com/klauspost/compress v1.20.3, github.com/molecule-man/go-brrr v1.3.1, github.com/valyala/bytebufferpool v1.0.0, golang.org/x/crypto v0.58.0, golang.org/x/net v0.62.0 and golang.org/x/sys v0.49.0, with golang.org/x/text v0.43.0 as an indirect requirement.

Several of these line up with source files. There are compression files (`compress.go`, `brotli.go`), platform-specific file serving (`fs_unix.go`, `fs_windows.go`) and fuzz tests. Because the module requires a very recent Go release, check your CI image and container base before adding it, or the build fails at module resolution rather than in your code.

Examples cover the common shapes, but websockets and routing are not in the root package

The `examples/` directory has helloworldserver, client, host_client, fileserver, letsencrypt and multidomain, each a starting point for one use. The README links the Go documentation examples, a list called Awesome fasthttp tools hosted under the fasthttp GitHub organization, best practices and a related projects section.

People search for fasthttp together with routers, websockets and HTTP/2. The subpackages visible in the repository are fasthttpadaptor, fasthttpproxy, fasthttputil and expvarhandler, and none of them is a router or a websocket layer. For routing or other features outside the core, check the related projects and the linked tools before assuming support. Read the best practices section before writing handlers, since a library tuned for reusing buffers punishes code that keeps references to request data after the handler returns.

Editorial conclusion

Choose fasthttp only if your Go service handles thousands of small to medium requests per second and needs steady low millisecond latency, and you accept an API that is not identical to net/http. Stay on net/http if you want the easier, more general package, because the project itself says the difference goes unnoticed in most cases. Before switching, rerun the README benchmark commands on your own hardware and handler.

Frequently asked questions

What is fasthttp?

fasthttp is a fast HTTP implementation for Go, covering both server and client, tuned for high performance with zero memory allocations in hot paths. It is MIT licensed.

Is fasthttp better than net/http in Go?

Only in edge cases. The README says to avoid fasthttp unless you handle thousands of small to medium requests per second and need consistent low millisecond latency, and that net/http is much better for most cases.

How much faster is fasthttp than net/http?

The README benchmarks say the server is up to 6 times faster and the client up to 4 times faster than net/http. The repository description says up to 10x.

Official sources

  1. Issues
  2. License: MIT
  3. README
  4. Releases
  5. valyala/fasthttp on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/valyala-fasthttp.svg)](https://hysenlabs.com/projects/valyala-fasthttp)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/valyala-fasthttp.svg)](https://hysenlabs.com/projects/valyala-fasthttp)

Was this useful?