Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ztellman/aloha
a simple, friendly webserver
https://github.com/ztellman/aloha
Last synced: 5 days ago
JSON representation
a simple, friendly webserver
- Host: GitHub
- URL: https://github.com/ztellman/aloha
- Owner: ztellman
- Archived: true
- Created: 2011-12-28T02:35:30.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2014-01-19T02:28:12.000Z (almost 11 years ago)
- Last Synced: 2024-10-28T13:06:12.503Z (15 days ago)
- Language: Clojure
- Homepage:
- Size: 210 KB
- Stars: 36
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
Aloha is a webserver, implemented using [Netty](http://netty.io) and Clojure.
```clj
(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](https://github.com/ztellman/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](http://mxcl.github.com/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](http://forrst.com/posts/Fixing_ApacheBench_bug_on_Mac_OS_X_Lion-wku).
### 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.