How valyala/fasthttp works
fasthttp is a high-performance Go HTTP implementation with server and client APIs. The principal server workflow accepts a connection, processes HTTP requests through a handler, and writes responses; the client workflow sends requests and receives responses. The repository also provides load balancing, proxy dialing, preforking, TCP listener options, net/http adaptation, and utility handlers. The sampled excerpts show only parts of the main runtime, so uncertain internal handoffs are omitted rather than inferred.
Main entry points: http.go HTTP Core · server.go HTTP Server · client.go HTTP Client · request.go net/http Adapter
Components 18
HTTP Runtime
- HTTP Server
server.go - HTTP Core
http.go - Headers
header.go - URI Parsing
uri.go - Compression
compress.go
Client Networking
- HTTP Client
client.go - Client Balancer
lbclient.go - Proxy Dialer
fasthttpproxy/dialer.go
Server Networking
- Prefork Server
prefork/prefork.go - Reuseport Listener
reuseport/reuseport.go - TCP Listener
tcplisten/tcplisten.go
Adapters and Handlers
- net/http Adapter
fasthttpadaptor/request.go - Profiling Handler
pprofhandler/pprof.go - Expvar Handler
expvarhandler/expvar.go
Utilities
- In-memory Listener
fasthttputil/inmemory_listener.go - Pipe Connections
fasthttputil/pipeconns.go - Stackless Writer
stackless/writer.go
Other components
- Application
Connections 12
- Application → HTTP Server: serves requests
- Application → HTTP Client: sends requests
- Application → Client Balancer: balances requests
lbclient.go - Prefork Server → HTTP Server: wraps server
prefork/prefork.go - Reuseport Listener → TCP Listener: creates listener
reuseport/reuseport.go - Profiling Handler → net/http Adapter: adapts handlers
pprofhandler/pprof.go - net/http Adapter → HTTP Core: converts requests
fasthttpadaptor/request.go - HTTP Client → Proxy Dialer: uses dial function
- HTTP Server → HTTP Core: handles HTTP
- HTTP Core → Headers: uses headers
- HTTP Core → URI Parsing: parses targets
- HTTP Core → Compression: compresses bodies