Every Go backend team eventually hits the same fork in the road: stick to the standard library net/http, add Chi (optionally with Huma for OpenAPI 3.1), reach for Gin, or bet on Fiber for maximum raw numbers.
Most comparison posts still repeat 2023 benchmarks from before net/http’s Go 1.22+ pattern routing, before Fiber v3, and before Go 1.27 (go1.27.3) shipped generic methods, encoding/json/v2, and stdlib uuid. I benchmarked all five stacks side-by-side on Go 1.27.3 to see where the nanoseconds and heap allocations actually go.

Go 1.27 Web APIs: the short answer
| Stack (Go 1.27.3, arm64) | Engine | GET /health |
GET /users/{id} + auth |
POST /orders + validate |
POST Allocs |
|---|---|---|---|---|---|
net/http (stdlib) |
net/http |
1,768 ns (27 allocs) |
2,112 ns (35 allocs) |
2,187 ns (29 allocs) |
7.0 KB (29) |
Chi v5.5 |
net/http |
1,893 ns (29 allocs) |
2,386 ns (38 allocs) |
2,205 ns (31 allocs) |
7.4 KB (31) |
Chi + Huma v2.41 |
net/http |
2,019 ns (28 allocs) |
2,591 ns (36 allocs) |
3,718 ns (47 allocs) |
7.9 KB (47) |
Gin v1.12 |
net/http |
1,785 ns (28 allocs) |
2,168 ns (35 allocs) |
2,243 ns (33 allocs) |
7.1 KB (33) |
Fiber v3.7 |
fasthttp |
785 ns (17 allocs) |
1,079 ns (29 allocs) |
842 ns (12 allocs) |
2.0 KB (12) |
Two findings jump straight off the table:
- Standard library
net/httpis no longer “slow.” On Go 1.27.3, plainhttp.NewServeMux()tied or edged outGin v1.12on every single route while carrying zero third-party dependencies. - A single database query dwarfs every router difference. A 2 ms PostgreSQL query equals
2,000,000 ns. Even the gap between Fiber (842 ns) and Chi + Huma (3,718 ns) is under 0.15% of total request latency.
Go HTTP fundamentals (if you are new to Go)
Unlike Python (Django), Java (Spring), or TypeScript (NestJS), Go does not ship a monolithic web framework. Most production Go APIs are assembled from small, focused building blocks:
http.Handler: Anything withServeHTTP(w http.ResponseWriter, r *http.Request). Standard library handlers,Chi, and hundreds of community libraries all speak this exact interface.- Middleware: A wrapper
func(http.Handler) http.Handlerthat runs before and after your handler — logging, auth headers, panic recovery, or rate limits. - How to read benchmark numbers:
ns/op= nanoseconds per request inside the router + JSON layer (1,000 ns = 1 µs,1,000,000 ns = 1 ms).B/opandallocs/op= heap bytes and object allocations per request. Fewer allocations mean less work for Go’s garbage collector (GC) at high concurrency.

Benchmark setup and methodology
Engineering Basis: All 15 benchmarks ran locally on Go 1.27.3 (
darwin/arm64) usinggo test -bench=. -benchmemagainstnet/httpstdlib,github.com/go-chi/chi/v5 v5.5.0,github.com/danielgtaylor/huma/v2 v2.41.0,github.com/gin-gonic/gin v1.12.0(ReleaseMode), andgithub.com/gofiber/fiber/v3 v3.7.0.
Each framework implemented the exact same three endpoints:
GET /health— serialize a small JSON status payload.GET /users/{id}?include=roles— validate anX-Api-Keyheader in middleware/handler, extract a path parameter and query parameter, and return JSON.POST /orders— parse JSON (userId,amount,currency) and enforce positive integer/number and enum constraints (EUR/USD).

The real divide: net/http ecosystem vs. Fiber’s fasthttp
Notice how net/http, Chi, Huma, and Gin all sit within a tight band (~1,768–2,591 ns on GET), while Fiber v3 drops to 785–1,079 ns. That gap has little to do with routing algorithms — it comes from the underlying HTTP engine:

- The
net/httpbus (stdlib,Chi,Gin): Standardhttp.Handlermiddleware (func(http.Handler) http.Handler), OpenTelemetry (otelhttp), rate limiters, andnet/httptest servers work natively acrossstdlibandChi.Ginwrapsnet/httptoo, though handlers use*gin.Contextrather thanhttp.ResponseWriterand*http.Request. - The
fasthttpisland (Fiber v3):fasthttpbypassesnet/httpcompletely, pooling byte slices and request contexts to minimize GC pressure. The catch: standardnet/httpmiddleware does not work directly, HTTP/2 and HTTP/3 require extra configuration, and holding afiber.Ctxreference after a handler spawns a goroutine causes subtle data races unless you copy values explicitly.
Side-by-side code: net/http vs. Chi vs. Gin vs. Fiber v3
To see how each stack feels day to day, here is the exact same authenticated GET /users/{id} endpoint across all four:
// 1. Standard library net/http (Go 1.22+ / 1.27): zero dependenciesmux := http.NewServeMux()mux.HandleFunc("GET /users/{id}", func(w http.ResponseWriter, r *http.Request) { id := r.PathValue("id") w.Header().Set("Content-Type", "application/json") _ = json.NewEncoder(w).Encode(map[string]string{"id": id})})// 2. Chi v5: same http.Handler contract, clean groups + scoped r.Use()r := chi.NewRouter()r.Use(apiKeyMiddleware) // MUST be registered before routesr.Get("/users/{id}", func(w http.ResponseWriter, r *http.Request) { id := chi.URLParam(r, "id") w.Header().Set("Content-Type", "application/json") _ = json.NewEncoder(w).Encode(map[string]string{"id": id})})// 3. Gin v1.12: custom *gin.Context with built-in JSON helpersr := gin.New()r.GET("/users/:id", apiKeyGinMiddleware, func(c *gin.Context) { c.JSON(http.StatusOK, gin.H{"id": c.Param("id")})})// 4. Fiber v3: Express-style signature backed by fasthttpapp := fiber.New()app.Get("/users/:id", apiKeyFiberMiddleware, func(c fiber.Ctx) error { return c.JSON(fiber.Map{"id": c.Params("id")})})Notice the key takeaway for beginners: moving from net/http to Chi keeps your exact http.Handler signature and middleware, whereas Gin and Fiber introduce their own context types.
Why golang chi + Huma is winning production Go teams
If net/http already supports mux.HandleFunc("GET /users/{id}", ...) since Go 1.22, why do teams still install Chi — and pair it with Huma?
- Nested route groups and scoped middleware:
net/httpstill lacks cleanr.Route("/v1", ...)and per-groupr.Use(authMiddleware)ergonomics. Chi adds them in ~125 nswith zero lock-in. - Typed contracts and OpenAPI 3.1 without Swagger comment soup: With Gin, teams often maintain struct
bindingtags separately from@Summary/@Paramdoc comments. Huma derives request validation, JSON Schema, and OpenAPI 3.1 specs from a single Go input/output struct:
// Chi + Huma v2: typed validation + automatic OpenAPI 3.1 specr := chi.NewMux()api := humachi.New(r, huma.DefaultConfig("Orders API", "1.0.0"))
type OrderInput struct { Body struct { UserID int64 `json:"userId" minimum:"1"` Amount float64 `json:"amount" exclusiveMinimum:"0"` Currency string `json:"currency" enum:"EUR,USD"` }}
huma.Register(api, huma.Operation{ OperationID: "create-order", Method: http.MethodPost, Path: "/orders", DefaultStatus: http.StatusCreated,}, func(ctx context.Context, in *OrderInput) (*OrderOutput, error) { return &OrderOutput{Body: OrderResp{Accepted: true, UserID: in.Body.UserID}}, nil})Yes, Huma’s full JSON Schema validation took 3,718 ns/op (47 allocs) vs 2,205 ns/op on raw Chi — a 1.5 µs cost that buys compile-time contracts, automatic 422 Unprocessable Entity RFC 9457 error bodies, and always-accurate /docs and /openapi.json endpoints.
What Go 1.27 changed for web APIs
Upgrading to Go 1.27 strengthens the minimal stdlib / Chi stack even further:
encoding/json/v2andjsontext: Lower-allocation JSON encoding/decoding in the standard library (up to ~30% cheaper small allocations), cutting the gap between standardencoding/jsonand third-party encoders likesonic.- Generic methods: Libraries and internal response helpers can now define type-parameterized methods directly on structs rather than wrapping everything in package-level helper functions.
- Standard library
uuid(with UUIDv7): Generate time-sortable primary keys (ideal for PostgreSQL B-tree indexes) without pulling external dependencies intogo.mod. - Goroutine leak profiling: Makes diagnosing stuck HTTP handlers and background workers dramatically easier in long-running microservices.
Common gotchas and production http.Server defaults
Whichever router you pick, avoid these four common pitfalls in production Go services:
net/http: Always cap request body size withr.Body = http.MaxBytesReader(w, r.Body, 1<<20)before decoding JSON so a single oversized payload cannot exhaust memory.Chi: Declarer.Use(...)before registering routes on that router/group, or Chi panics at startup.Gin: Preferc.ShouldBindJSON(&req)overc.BindJSON(&req)(which writes a400response itself), and always callcp := c.Copy()before passing context into a background goroutine.Fiber v3: Becausefasthttpreuses buffers across requests, strings returned byc.Params("id")orc.Body()become invalid once the handler returns — copy them explicitly if you pass them to a goroutine.
Finally, never ship bare http.ListenAndServe(":8080", handler) in production. Wrap net/http, Chi, or Gin in an http.Server with explicit timeouts and graceful shutdown:
srv := &http.Server{ Addr: ":8080", Handler: r, // works identically for net/http, Chi, and Gin ReadHeaderTimeout: 5 * time.Second, ReadTimeout: 15 * time.Second, WriteTimeout: 15 * time.Second, IdleTimeout: 60 * time.Second,}
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)defer stop()
go func() { _ = srv.ListenAndServe() }()<-ctx.Done()
shutdownCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second)defer cancel()_ = srv.Shutdown(shutdownCtx)When to choose net/http, Chi, Gin, or Fiber

- Pick
Chi + Huma(orChialone) for most production Go REST APIs: you stay 100% compatible withnet/httpand OpenTelemetry while getting clean middleware scoping and OpenAPI 3.1. Start withnet/httpif you have under 10 routes — migrating toChilater takes 15 minutes with zero handler rewrites. - Pick pure
net/httpfor small internal services, webhooks, or teams committed to zero external router dependencies. - Pick
Ginif your team already standardizes on Gin’s middleware ecosystem and wants fast onboarding without rewriting existing conventions. - Pick
Fiber v3for edge proxies, high-fanout JSON relays, or teams coming from Node.js/Express who explicitly acceptfasthttp’s non-stdlib trade-offs.
To reproduce these numbers on your own hardware, run go test -bench=. -benchmem -count=5 ./... using httptest.NewRecorder() against each router’s ServeHTTP (or Fiber’s app.Test) without network socket noise.






From the community
Discussion on Mastodon & Bluesky
Replies to this article from the open web, pulled in live. No ads, no tracking scripts.
Reply there — it shows up here automatically.