A C++11 single-header library for building HTTP/HTTPS servers and clients with blocking socket I/O.
valyala/fasthttp
Fast HTTP server and client implementation for Go, designed for high-throughput workloads and low allocation overhead.
- Stars
- 23,489
- Forks
- 1,883
- Open issues
- 66
- Last commit
- 2 days ago
What is it?
fasthttp is an HTTP implementation for Go that provides both server and client APIs. It is built for edge cases with very high request volume, reusing request and response objects and avoiding allocations on hot paths. The README benchmarks compare it against net/http, reporting a server that is up to about 6 times faster and a client up to about 4 times faster in the measured setups.
The API is intentionally different from net/http. Handlers take a single *RequestCtx argument, and there is no ServeMux, so routing is provided by third-party routers or frameworks such as Fiber. Response headers and body can be written in any order before the handler returns. Migrating existing code requires adapting handlers and avoiding references to the context after a handler returns.
The project's README recommends net/http for most applications, since it is easier to use, handles more HTTP corner cases, and supports HTTP/2. fasthttp is best suited to services that handle thousands of small-to-medium requests per second and need consistent low latency.
Key features
- 01Server and client APIs with reuse of request and response objects to reduce allocations.
- 02Handlers take a single RequestCtx, and headers and body can be written in any order.
- 03Supports reuseport listeners and per-core deployment patterns for multi-core scaling.
- 04Includes helpers for converting net/http handlers, file serving, and timeout handling.
- 05Requires Go 1.26 or newer, per the README's FAQ.
Use cases
- High-throughput API gateways or proxies handling large volumes of small requests.
- Latency-sensitive Go services where allocation pressure is a measured bottleneck.
- Edge services serving many keep-alive connections from a single server.
Quick start
- 1
Install the library with Go
go get -u github.com/valyala/fasthttp
Things to know
- fasthttp is not a drop-in replacement for net/http and its API differs.
- The README says net/http is usually the better choice unless you need very high throughput.
Topics
FAQ
- What is fasthttp?
- Fast HTTP server and client implementation for Go, designed for high-throughput workloads and low allocation overhead. fasthttp is an HTTP implementation for Go that provides both server and client APIs. It is built for edge cases with very high request volume, reusing request and response objects and avoiding allocations on hot paths. The README benchmarks compare it against net/http, reporting a server that is up to about 6 times faster and a client up to about 4 times faster in the measured setups.
- Is fasthttp free to use? What license does it have?
- fasthttp is open source under the MIT license. Check the license terms before using it in commercial products.
- Is fasthttp still maintained?
- Actively maintained. The last commit to fasthttp was on Oct 21, 2026.
- What can I use fasthttp for?
- High-throughput API gateways or proxies handling large volumes of small requests. Latency-sensitive Go services where allocation pressure is a measured bottleneck. Edge services serving many keep-alive connections from a single server.
- How do I install fasthttp?
- Install the library with Go: go get -u github.com/valyala/fasthttp
- Where can I get fasthttp?
- The source code and installation instructions are on GitHub: https://github.com/valyala/fasthttp
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A simple, elegant Python HTTP library for sending HTTP/1.1 requests with sessions, cookies, auth, and JSON support.
A high-performance web server, reverse proxy, load balancer, API gateway and content cache written in C.
A high-performance HTTP web framework for Go with a Martini-like API, built for REST APIs, web apps and microservices.
A type-safe HTTP client for Android and Java that turns annotated interface methods into network calls.
Open-source API development ecosystem for sending REST, GraphQL, WebSocket, SSE, Socket.IO and MQTT requests, offered as web, desktop and CLI apps.