Home/Code Samples/HTTP Server

HTTP server in Rust vs Go:
same endpoint, both languages, full code.

Before you read anything into throughput

TechEmpower's Round 23 plaintext test ran on 56-core Xeon Gold 6330 servers behind 40 Gbps networking, which lifted the theoretical network-bound results by roughly 4x over earlier rounds. Fiber publishes its own result from that round: 11,987,976 responses per second at 1.0 ms average latency. Any league table you find that peaks around 7 million req/s is older than this hardware.

We do not reproduce a per-framework ranking here: TechEmpower serves results through an interactive viewer rather than a citable export, and the project archived its benchmark repository in March 2026. Both frameworks below will saturate a network link long before they become your bottleneck, so pick on ergonomics, not on these numbers.

Sources: techempower.com/benchmarks · docs.gofiber.io/next/extra/benchmarks · checked October 2026

Minimal HTTP server with routing

RUST / Axum
use axum::{
    routing::get,
    Router,
    extract::Path,
};

#[tokio::main]
async fn main() {
    let app = Router::new()
        .route("/", get(|| async { "Hello, World!" }))
        .route("/hello/:name", get(greet));

    let listener = tokio::net::TcpListener::bind(
        "0.0.0.0:3000"
    ).await.unwrap();

    axum::serve(listener, app)
        .await
        .unwrap();
}

async fn greet(Path(name): Path<String>) -> String {
    format!("Hello, {name}!")
}
GO / net/http
package main

import (
    "fmt"
    "net/http"
    "strings"
)

func main() {
    mux := http.NewServeMux()

    mux.HandleFunc("GET /", func(
        w http.ResponseWriter,
        r *http.Request,
    ) {
        fmt.Fprintln(w, "Hello, World!")
    })

    mux.HandleFunc("GET /hello/{name}", greet)

    http.ListenAndServe(":3000", mux)
}

func greet(w http.ResponseWriter, r *http.Request) {
    name := strings.TrimPrefix(r.URL.Path, "/hello/")
    fmt.Fprintf(w, "Hello, %s!", name)
}

Go 1.22+ (Feb 2024): net/http's ServeMux now supports HTTP method routing (GET /path) and path parameters ({name}) in the pattern directly. Before 1.22, you needed a third-party router like gorilla/mux or chi. This eliminates the main reason teams reached for frameworks. Rust's Axumuses tower-service middleware, which makes adding auth, logging, and rate-limiting composable and type-safe, but adds cognitive overhead vs Go's handler function signature.

More code samples →Full benchmark data →Cloudflare's Pingora deep-dive →