Skip to content

ayushanand18/crazyhttp

Repository files navigation

crazyhttp

crazyhttp

Go Tests

A modern HTTP server library written in pure Go for faster prototyping.

Note

Faster alternative to FastAPI, natively written in Golang.

Why use it?

  1. Fast prototyping, get started in less than 10 lines of code <- support H/1.1,2,3 without extra LOC.
package main

import (
	"context"
	"log"

	crazyserver "github.com/ayushanand18/crazyhttp/pkg/server"
	"github.com/ayushanand18/crazyhttp/pkg/types"
)

func main() {
	ctx := context.Background()

	server := crazyserver.NewHttpServer(ctx)
	if err := server.Initialize(ctx); err != nil {
		log.Fatalf("Server failed to Initialize: %v", err)
	}

	server.GET("/test").Serve(func(ctx context.Context, request interface{}) (response interface{}, err error) {
			return "Hello World from GET.", nil
		})

	if err := server.ListenAndServe(ctx); err != nil {
		log.Fatalf("Server failed to start: %v", err)
	}
}
  1. Built-in support for MCP, let your server accept MCP requests and handle them.
  2. Focus on server performance, benchmark results here

Support

  1. Supports HTTP v1.1, v2, v3 (+TLS).
  2. Supports HTTPS (self-signed/CA issued TLS Certificates) (guide to trust it locally on machine too).
  3. Supports streaming HTTP responses (LLM/media use-cases).

Table of Contents

Installation

Import the Go package in your service using

go mod add github.com/ayushanand18/crazyhttp

Benchmark Results

Note

More information here

Parameter crazyhttp::h1 FastAPI (H/1.1) crazyhttp::h3 crazyhttp::h3 [latest]
Startup Time 0.005 s 0.681 s 0.014 s 4.4499ms
RTT (p50) 1.751ms
RTT (p90) 6.88 ms 7.68 ms 4.49 ms 3.765ms
RTT (p95) 8.97 ms 9.34 ms 7.74 ms 4.796ms
RTT (p99) 7.678ms

Tested by using time on Linux. These times are an average of 3 consecutive runs so as to offset system load irregularities however these figure might (and probably shall) differ on each and every run.

  • Startup Time: 153x faster than FastAPI.
  • 50.97% faster than FastAPI (p90).
  • 48.65% faster than FastAPI (p95).

Examples

This repository includes examples for building a simple server over HTTP/3.

Acknowledgements

Other performant libraries form the backbone of this repository, and made it possible to build. We utilise the following open source libraries for developing ashttp3lib

Thanks!

About

A modern HTTP server library written in pure Go for faster prototyping.

Resources

License

Stars

Watchers

Forks

Packages

No packages published