🚀 Web server. 53 Commits
2024-03-28 15:38:10 +01:00
content Removed net/http 2024-03-26 22:46:16 +01:00
examples/hello Removed net/http 2024-03-26 22:46:16 +01:00
testdata Improved API 2024-03-16 15:22:47 +01:00
.gitignore Added test data 2024-03-12 20:36:57 +01:00
Context_test.go Added server tests 2024-03-28 12:22:45 +01:00
Context.go Removed net/http 2024-03-26 22:46:16 +01:00
go.mod Renamed module 2024-03-22 15:08:24 +01:00
go.sum Updated dependencies 2024-03-15 10:06:17 +01:00
Handler.go Renamed module 2024-03-22 15:08:24 +01:00
Header.go Added server tests 2024-03-28 12:22:45 +01:00
http.go Added server tests 2024-03-28 12:22:45 +01:00
README.md Added some benchmarks 2024-03-28 15:38:10 +01:00
Request_test.go Added server tests 2024-03-28 12:22:45 +01:00
Request.go Added server tests 2024-03-28 12:22:45 +01:00
Response_test.go Added server tests 2024-03-28 12:22:45 +01:00
Response.go Improved performance 2024-03-28 15:19:46 +01:00
Server_test.go Added more tests 2024-03-28 14:27:40 +01:00
Server.go Improved performance 2024-03-28 15:19:46 +01:00

web

Web server.

Features

  • High performance
  • Low latency
  • Radix tree routing

Installation

go get git.akyoto.dev/go/web

Usage

s := web.NewServer()

// Static route
s.Get("/", func(ctx web.Context) error {
	return ctx.String("Hello")
})

// Parameter route
s.Get("/blog/:post", func(ctx web.Context) error {
	return ctx.String(ctx.Get("post"))
})

// Wildcard route
s.Get("/images/*file", func(ctx web.Context) error {
	return ctx.String(ctx.Get("file"))
})

s.Run(":8080")

Tests

PASS: TestBytes
PASS: TestString
PASS: TestError
PASS: TestErrorMultiple
PASS: TestRequest
PASS: TestRequestHeader
PASS: TestRequestParam
PASS: TestWrite
PASS: TestWriteString
PASS: TestResponseCompression
PASS: TestResponseHeader
PASS: TestResponseHeaderOverwrite
PASS: TestPanic
PASS: TestRun
PASS: TestBadRequest
PASS: TestBadRequestHeader
PASS: TestBadRequestMethod
PASS: TestBadRequestProtocol
PASS: TestEarlyClose
PASS: TestUnavailablePort
coverage: 100.0% of statements

Benchmarks

wrk

wrk -t12 -c1000 -d2s http://127.0.0.1:8080/
Running 2s test @ http://127.0.0.1:8080/
  12 threads and 1000 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.83ms    2.07ms  33.95ms   88.04%
    Req/Sec    50.38k     5.34k   64.92k    71.67%
  1207398 requests in 2.03s, 46.06MB read
Requests/sec: 595860.16
Transfer/sec:     22.73MB

ali

ali --rate=10000 --duration=0 http://127.0.0.1:8080/
Latencies:
P50: 90μs
P90: 138μs
P95: 160μs

oha

oha -z 2s --no-tui http://127.0.0.1:8080/
Summary:
  Success rate:	100.00%
  Total:	2.0003 secs
  Slowest:	0.0034 secs
  Fastest:	0.0000 secs
  Average:	0.0002 secs
  Requests/sec:	265346.5118

go-wrk

go-wrk -c 1000 -d 2 http://127.0.0.1:8080/
Running 2s test @ http://127.0.0.1:8080/
  1000 goroutine(s) running concurrently
355214 requests in 1.97068379s, 8.81MB read
Requests/sec:		180249.11
Transfer/sec:		4.47MB
Avg Req Time:		5.547877ms
Fastest Request:	30.66µs
Slowest Request:	95.208812ms
Number of Errors:	0

License

Please see the license documentation.

© 2024 Eduard Urbach