Liking cljdoc? Tell your friends :D

Aloha is a webserver, implemented using Netty and Clojure.

(use 'aloha.core)

(start-http-server
  (fn [request]
    {:status 200
	 :headers {:content-type "text/plain"}
	 :body "Aloha!\n"})
  {:port 8080})

Aloha is a reference implementation of a Clojure/Netty webserver, or basically Aleph without any extraneous fluff. It exists as a reminder that Aleph could be faster, but also as a very fast, fully functional webserver in its own right.

You can use Aloha in your own project by adding this to your project.clj:

[aloha "1.0.1"]

Since much of Aloha's existence will be spent returning a single string over and over again, it's easy to start up a server for benchmarking.

$  lein run &
Server listening on port 8080.
$  curl localhost:8080
Aloha!

If you have any ideas on how to improve Aloha's performance, please send a pull request.

Benchmarking

In OS X

$  sudo sysctl -w net.inet.tcp.msl=1000
net.inet.tcp.msl: 15000 -> 1000
$  httperf --num-conns=16 --rate=16 --num-calls=100000 --port=8080
...

If you don't have httperf installed, try brew install httperf or port install httperf. If neither of those work, consider installing Homebrew.

If you want to be contrary and use ab instead, be aware that the ApacheBench binary is broken on OS X Lion. You can fix it following these instructions.

In Linux

$  echo 1 | sudo tee /proc/sys/net/ipv4/tcp_tw_reuse
1
$  httperf --num-conns=16 --rate=16 --num-calls=100000 --port=8080
...

If you don't have httperf installed, use your package manager of choice to install it.

Can you improve this documentation? These fine people already did:
ztellman & Zach Tellman
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close