/whip

Simple fast http server for nim based on httpbeast and nest for high performance routing

Primary LanguageNim

WHIP

WHIP is a high performance web application server based on the excellent https://github.com/dom96/httpbeast and routing provided by https://github.com/kedean/nest with some additonal optimizations.

WHIP is still in development and is not recomended for production use. Much is still missing or untested but for basic api use cases however, the performance numbers look pretty good so far (see below).

Its Simple

import ../whip, sugar, json

let w = initWhip()
w.onGet "/json/{name}", (w:Wreq) => w.send(%*{ "name": w.path("name")})
w.onGet "/text/{name}", (w:Wreq) => w.send("hello " & w.path("name"))
w.start()

Its Fast.

As fast as Httpbeast for simple routes and upto 3x faster than Jester for complex routing.

Compared to Go, it is a little quicker than Gin-gonic but slower than fastrouter.

Very unscientific benchmarks...

Framework Lang /text/{name} /json/{name} /text
Whip Nim 66.2k (0.15) 56.4k (0.17) 70.0k (0.14)
HttpBeast Nim N/A N/A 68.2k (0.14)
Jester Nim 16.2k (0.59) 15.6k (0.63) 56.7k (0.17)
Mofuw Nim 8.71k (1.14) 8.13k (1.23) 9.13 (1.23)
GinGonic Go 58.4k (0.14) 57.8k (0.15) 57.5k (0.15)
FastRouter Go 89.5k (0.09) N/A 90.3k (0.09)

Total Reqs/Sec (Mean latencies in ms) taken from the best of 3 wrk runs using 2 threads and 10 connections for 10 secs For latest results see [[results.txt]]

To run ..

./bench.sh -c

Its WIP

Coming soon..

  • middleware api
  • websockets (mqtt)
  • swagger docs
  • smarter headers
  • session storage (redis)
  • sql db adapters (postgrest, graphql)
  • smart caching
  • static html serving
  • html templates (jade)
  • authentication (oauth, jwt)
  • aws lambda interop